Campbell Ritchie

Marshal

Posts: 56193

171

posted 8 months 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: 56193

171

Stephan van Hulst

Saloon Keeper

Posts: 7927

143

posted 8 months 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 8 months 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.

:-)

OCAJP 7

Consider Paul's rocket mass heater. |