IEEE floating point numbers have a bit assigned to indicate the sign, which means you can technically have different binary representations of zero (+0 and -0). Is there an arithmetic operation I could do for example in C which result in a negative zero floating point value?
This question is inspired by another which called into question whether you can safely compare 0.0f
using ==
, and I wondered further if there is are other ways to represent zero which would cause float1 == 0.0f
to break for seemingly perfectly equal values.
[Edit] Please, do not comment about the safety of comparing floats for equality! I am not trying to add to that overflowing bucket of duplicate questions.
0.0f
using==
" – Adamski