Javascript:alert (0.1 + 0.2)
What would you think if you saw such a question? Everyone is sure the first reaction is 0.3, but considering I've already asked! I'll write an article about that naïve answer?
And then the people started torturing themselves, could it be 0.10.2?
And the results are still very windy.
0.30000000000000004
Come again, 0.1+0.7.
0.7999999999999999
This is due to the precision problem caused by the conversion of decimal to binary! Because the computer performs binary arithmetic, this accuracy error cannot be avoided when a decimal number cannot accurately convert the binary number. If this is a simple reason to describe or confusing, then go to the specific description behind the article!
And then, interesting thing, another interesting one.
parseint (0.0000008)
What's the result, you say 0, I say 8, and you say it's 8.
parseint (0.08)
Then this you say is 8, but I say 0 ... I think you're in a mess.
I searched for her 1100 degrees .... And then find the results
Many languages have precision problems with both floating-point and shaping operations '
Just maybe JS's a little bit more
Recognize the floating point arithmetic of javascript
The students who have studied JS know that the numbers in JS are represented by floating-point number, and the double-precision floating-point numbers are indicated using IEEE 754 standard.
IEEE 754 Standard floating-point number Introduction (Oh, this is the University of the composition of the reason for the knowledge of learning OH)
IEEE 754 specifies two basic floating-point formats : single-precision and double-precision.
The IEEE single-precision format has a valid digital precision (containing symbol number) and occupies a total of three digits.
IEEE double-precision format has a valid numeric precision (including symbol number) in the single digit and occupies a total of four bits.
Description: The basic floating-point format is a fixed format, and the corresponding decimal valid digits are 7-bit and 17-bit respectively. The basic floating-point format corresponds to a C + + type of float and double.
JavaScript you don't know about those things! (Digital computing-metamorphosis)