What is -0, which appears sometimes in my datasheet after some calculation? It’s an annoying little creature and shouldn’t, in my opinion, be tolerated.

There are a couple of possibilities. One is that the floating point format actually has two zeros, a positive zero and a negative zero. If you do a floating point multiplication or division between positive zero and a negative number, you will get negative zero as the result.

There doesn’t seem to be any way for an addition or subtraction to result in a negative zero, so you could add zero to your result, and that should take care of it.

The other possibility is that the result was a very small negative number, which your output pattern rounded to negative zero. That can be corrected by using the round( function to round to your desired precision.

1 Like