How is it possible that 0.0 == 0.0?
Campbell Ritchie
Marshal
Posts: 53094
124
posted 1 week ago
 1
The mathematicians will tell you that there is no such thing as 0. But computer arithmetic does not usually follow strict mathematical notions. It follows IEEE754 for floating‑point numbers. Look it up on Wikipedia or elsewhere. It mandates negative 0 and also that there is no difference between that and ordinary 0.
Note that does not apply strictly to the wrapper classes:Yes, I know d0 and d_0 are bad names for variables.
Note that does not apply strictly to the wrapper classes:Yes, I know d0 and d_0 are bad names for variables.
Campbell Ritchie
Marshal
Posts: 53094
124
Stephan van Hulst
Bartender
Posts: 6646
90
posted 1 week ago
They are equivalent, but not identical. The difference becomes clear when you divide something by zero and negative zero:
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
posted 1 week ago
Thanks Campbell for your nice post.
This post raised me other questions.
:)
Campbell Ritchie wrote:The mathematicians will tell you that there is no such thing as 0. But computer arithmetic does not usually follow strict mathematical notions. It follows IEEE754 for floating‑point numbers. Look it up on Wikipedia or elsewhere. It mandates negative 0 and also that there is no difference between that and ordinary 0.
Note that does not apply strictly to the wrapper classes:Yes, I know d0 and d_0 are bad names for variables.
Thanks Campbell for your nice post.
This post raised me other questions.
:)
Computers don't know Maths.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/ThreadBoostfeature
