-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way of disabling exponential notation when encoding doubles #374
base: main
Are you sure you want to change the base?
Conversation
Very nice, thanks for the PR! I'll take a look shortly. |
Could you please address the failing CI jobs? Missing documentation comments and SwiftLint rule violations. Also CMake updates. |
@@ -254,6 +259,14 @@ public final class Emitter { | |||
|
|||
/// Set the style for mappings (dictionaries) | |||
public var mappingStyle: Node.Mapping.Style = .any | |||
|
|||
/// Set the style for formatting doubles | |||
public static var doubleFormatStyle: NumberFormatStyle = .scientific |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A static var
is not compatible with Swift 6 language mode. If we refactor this as an instance variable we can revitalize this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A static var is not compatible with Swift 6 language mode. If we refactor this as an instance variable we can revitalize this PR.
Closes #279
In current version all doubles are encoded in a scientific notation:
produces:
6.85e+0
The proposed change is to add a static option to
Emitter.Options
class, so it can be used as follows:which produces the expected result:
6.85
YAMLEncoder
object is also supported, as well as numbers with zero fraction part, which are not saved as integers. For example, the following code:generates the expected result:
6.0