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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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.