Skip to content

Serialization error on very small floating point values #374

@KirbyER

Description

@KirbyER

Very small floating point values serialize with an extra ".0" at the end:

fn main() {
  let config = ser::PrettyConfig::new();
  let result = ser::to_string_pretty(&0.00000000000000005, config).unwrap();
  assert_eq!(result, "0.00000000000000005");
}
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"0.00000000000000005.0"`,
 right: `"0.00000000000000005"`', src/main.rs:6:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions