IEEE 754 - float binary notation and JSON #118283
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
It is the same value. #1630 is what tracks adding support for parsing/formatting using the IEEE 754 hexadecimal based format. The term JSON, by spec, notably does not support the hexadecimal based character sequence format for its numbers, so this wouldn't be usable there by default even if it were added. You'd have to explicitly define it as a |
Beta Was this translation helpful? Give feedback.
This is not how you compare equality of floating-point values. As you can see from the below, these parse to the same value and have the same bitwise representation.
This is for the same reason you cannot do something like
1.0
vs1
vs1.000
vs10e-1
and so on. They all represent the same value, even though the string representation differs. As such, you must parse the string to a double and check the double value represented is the same.Almo…