Live data from Hacker News

In Erlang/OTP 27, +0.0 will no longer be exactly equal to -0.0

erlangforums.com

1–10 of 236 posts

Re: In Erlang/OTP 27, +0.0 will no longer be exactly equal to -0.0

#6
post #5

This feels like a bad idea. Treating +0 and -0 as unequal because they have different bit patterns is no more correct than treating two NaNs as equal because they have the same bit pattern. Zero is zero.

Unless you’re approaching the limit of 0 from one side

But yeah, you’re right

Re: In Erlang/OTP 27, +0.0 will no longer be exactly equal to -0.0

#8
post #3

As a general rule, if you find yourself comparing floating point numbers, that's probably not what you want. I'm wondering what they are going to do with other operators, >=, <= etc

This smells like the right way to think about things. Whenever thinking of real life measurements represented as real numbers, equality is always fuzzy — up to some resolution, and it would be better to make that explicit.

Re: In Erlang/OTP 27, +0.0 will no longer be exactly equal to -0.0

#9
post #5

This feels like a bad idea. Treating +0 and -0 as unequal because they have different bit patterns is no more correct than treating two NaNs as equal because they have the same bit pattern. Zero is zero.

Zero is zero, but signs are a direction. There are multiple parts to numbers.

Stand in place and turn around: how far did you go from where you started?

Nonetheless, I agree. It's a bad idea.

Re: In Erlang/OTP 27, +0.0 will no longer be exactly equal to -0.0

#10
post #4

Can anyone fill me in what the meaning of == vs =:= in Erlang is? Since after the change +0. == -0. but not +0. =:= -0.

=:= is supposed to be "exactly equals". An example given in the docs[1]:

    1> 1==1.0.
    true
    2> 1=:=1.0.
    false
You can think of it as analogous to == vs === in JS, except that the "type safety" here really only refers to different numeric types (and in JS there is no such distinction)

[1]: https://www.erlang.org/doc/reference_manual/expressions.html...

Post reply on HN