java - How can a primitive float value be -0.0? What does that mean? -



java - How can a primitive float value be -0.0? What does that mean? -

how come primitive float value can -0.0? mean? can cancel feature?

when have:

float fl;

then fl == -0.0 returns true , fl == 0. when print it, prints -0.0.

because java uses ieee standard floating-point arithmetic (ieee 754) defines -0.0 , when should used.

you can around problem adding 0.0

e.g.

double.tostring(value + 0.0);

see: java floating-point number intricacies

operations involving negative zero ... (-0.0) + 0.0 -> 0.0

java floating-point

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -