3 ms·
the Erlang VM said "screw IEEE": iex(1)> -0.0 === 0.0 true there's also explicitly no infinity or NaN, there is a software throw for all (core) implem
by dnautics 6y ago
the Erlang VM said "screw IEEE":
iex(1)> -0.0 === 0.0
true
there's also explicitly no infinity or NaN, there is a software throw for all (core) implemented function domain failures.
This has, however, recently come up for Nx (numerical elixir) which had to implement and standardize ways to shim these IEEE concepts back into the VM for interop purposes.
- recursive 6y agoIs there any language that treats the zeros as unequal? That would seem like the real "screw IEEE".
- dnautics 6y agoin the specific case of erlang, and the erlang beam vms, 0 !== 0.0 Of course 0 == 0.0 I imagine if they had chosen to follow IEEE, it would have been that 0.0 !== -0.0 and 0.0 == 0.0.
- recursive 6y agoI don't know erlang, but it looks to me like that's a difference between types. (integer vs float) Is there a language that treats different float values of zero as unequal? That would be surprising to me. And possibly silly.
- dnautics 6y agoWhat a guess! I guessed "Julia" and that is correct: https://stackoverflow.com/questions/38601141/what-is-the-difference-between-and-comparison-operators-in-julia https://stackoverflow.com/questions/38601141/what-is-the-dif... In Julia 0.0 == -0.0 but 0.0 === -0.0 evaluates to false. Note that -0.0 and 0.0 are different at the binary representation level, which is what === checks for.
- OneWingedShark 6y ago> This has, however, recently come up for Nx (numerical elixir) which had to implement and standardize ways to shim these IEEE concepts back into the VM for interop purposes. This would have been an excellent place to use Ada. The package "Interfaces" has types exactly for IEEE Floats: `Interfaces.IEEE_Float_64`. You could then get rid of non-numeric representations (raising `Constraint_Error` instead) via the following subtype-definition: subtype Float is Interfaces.IEEE_Float_64 range Interfaces.IEEE_Float_64'Range; (I've thought about writing an Erlang in Ada, hoping to tie together Erlang's actors w/ Ada's Task where possible [ie focus on interop], but haven't found any Erlang language definition that's anywhere near recent.)