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
Comments (2)
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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
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.