News for hackers. Stuff that matters.
Re:How does your programming language handle “minus zero” (-... by mcintyre1994 on Friday March 05, 2021 @07:32AM (#26356106)
I think you're right that they're indistinguishable, in that -0.0 == 0.0

The division by 0 in that article gives the same ArithmeticError in each case, notice the 0.0 in both errors:

    iex(8)> 1.0 / -0.0
    ** (ArithmeticError) bad argument in arithmetic expression: 1.0 / 0.0
        :erlang./(1.0, 0.0)
    iex(8)> 1.0/0.0
    ** (ArithmeticError) bad argument in arithmetic expression: 1.0 / 0.0
        :erlang./(1.0, 0.0)
It's also ignored when rounding:

    iex(10)> Float.round(-0.01, 1)
    0.0
    iex(11)> Float.round(0.01, 1)
    0.0

There are no comments on this comment yet.