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

c# - Move local mssql database to webhosted MYSQL -

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -