toml icon indicating copy to clipboard operation
toml copied to clipboard

Regression on float serialization

Open gcandal opened this issue 2 years ago • 5 comments

With 0.6 , the serialization of floats changed. When serializing 0.1, the results are:

  • Before, with 0.5: 0.1. Relied on Display
  • Now, with 0.6: 0.10000000149011612. Relies on serde

Using a number that can be precisely represented as a float, like 0.0625, yields the same result for both versions.

I don't know if this is something you want to do, but serde_json uses a custom formatter that relies on ryu for this.

Related to this, but on the deserialization side, serde_json offers two alternative features which you might want to give a look.

gcandal avatar Jan 24 '23 16:01 gcandal