PHP weird result of multiplying by -1

$res = 0.0 * -1.0; 

I get float -0

What is this weird behavior?

+6
source share
2 answers

Floating point numbers allow you to have a signed zero .

You should not worry, however, as +0.0 === -0.0 ( demo ) . (Not that you used such a comparison for float.)

+8
source

Since floating point is +0 and -0 .

+6
source

Source: https://habr.com/ru/post/909882/


All Articles