Java – double counting that produces odd results
See English answer > is floating point math broken? 28
Solution
Oh, I like these... These are caused by inaccuracies in double representation. Floating point operations are full of these It is usually caused by repeated numbers in binary (i.e. base-2 floating point representation) For example, in decimal 1 / 3 = 0.3333 ', binary 1 / 10 is a repeating number, which means that it cannot be represented perfectly Try this: 1 – 0.1 – 0.1 – 0.1 – 0.1 You won't get 0.6
The above is all the contents of Java - Double calculation that produces odd results collected and sorted by programming house for you. I hope this article can help you solve the program development problems encountered by Java - Double calculation that produces odd results.
If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.