Search Issue Tracker
Won't Fix
Votes
0
Found in
2017.3.0b6
Issue ID
964147
Regression
No
Float values, serialized with JsonUtility.ToJson, are sometimes too precise in the resulting json
To reproduce:
1. Open the project, attached by the tester (floatSerialization.zip)
2. Open the "scene" scene
3. Enter Play mode
4. Open the Output..json file that is located in C:\Temp
5. Observe the values in the .json
Expected: float values are serialized as they were written in the script
Actual: 1.24f in code becomes 1.2400000095367432 in .json, but 1.25f becomes 1.25 in .json
Reproduced in 5.6.4p2, 2017.1.2p2, 2017.2.0p1, 2017.3.0b6, 2017.3.0b8, 2018.1.0a3
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Trail Renderer visual doesn't match the positions of vertices when they have been offset
- [Mobile] The Material is not visible when using the Decal Renderer Feature
- Uncaught TypeError: Cannot read properties of undefined is thrown when the tab is inactive for several minutes
- Crash on mono_array_length when building a project
- "StackOverflowException" error when changing spline curve type from "Bezier" to "Auto" in the "Element Inspector"
ClockStone_Helmut
Mar 27, 2018 13:22
That is not fixable because 1.24f in code actually is 1.2400000095367432 in code. 1.24 can not be represented exactly as binary float in memory. That's why the compiler translates it to 1.2400000095367432 already. There is nothing the Unity developers can do to change that. It has nothing to do with JSON.
You can check if a number can be represented exactly here
http://www.exploringbinary.com/floating-point-converter/
hippogames
Dec 01, 2017 10:04
Why it's in Won't Fix state? It's annoying for me too.