Thursday 21 January 2016

Julia: Positive and Negative zero


Julia floating point numbers have two zeros, 0.0 (represents positive zero), -0.0 (represents negative zero). Ideally these two values are equal, but have different representation while storing.

julia> bits(0.0)
"0000000000000000000000000000000000000000000000000000000000000000"

julia> bits(-0.0)
"1000000000000000000000000000000000000000000000000000000000000000"

julia> 0.0==-0.0
true



Previous                                                 Next                                                 Home

No comments:

Post a Comment