Home >Backend Development >Golang >Go boss realizes his conscience and is willing to clear the map?
The same thing was discussed back and forth, closed and opened again, new ones were created after being closed, new ones were banned, new arguments were discovered, and then new ones were created. Open new one. This is very common in the workplace, and it also appears in Go proposal discussions...
What I want to share today is a controversy over NaN in Go map and the possible upcoming API increase.
In computer science, there is a magic The value is called: NaN (Not a Number, not a number). It is a class of values of numeric data type that represents undefined or unrepresentable values. Often used in floating point operations. NaN was first introduced in the 1985 IEEE 754 floating-point standard.
There will be problems when storing and comparing NaN values. Because when judging whether a value is NaN, the comparison cannot be made by judging x=NaN or x≠NaN. But because NaN is never equal to itself, you can judge whether x is a NaN value by judging x=x or x≠x, which will return False and True respectively.
When NaN is compared with another floating point number x (where x can be a normal value, plus or minus infinity, or NaN), the comparison results are as follows:
Comparison | Result |
---|---|
NaN ≥ x | False |
NaN ≤ x | False |
NaN > x | False |
NaN < x | False |
NaN = x | False |
True |
The above is the detailed content of Go boss realizes his conscience and is willing to clear the map?. For more information, please follow other related articles on the PHP Chinese website!