
#Gang beasts 0.0.3 controls code
This affects all code in the compiler that has to reason about exact equality.
#Gang beasts 0.0.3 controls free
When X and Y are the exact same it shouldn’t matter whether we return X or Y from the first clause: if the compiler deduces that it’s cheaper to return X it should be free to do so, but 0.0 =:= -0.0 makes that impossible because we could return 0.0 when the user wanted -0.0 or vice versa. I’m not a floating point expert, but, per the Comparison section on the Wikipedia page on signed zero, won’t this break IEE 754 compatibility? The > is > and > is > 1> =:= >.Ī) 8 bits of 0 + 56 bits of 0 ( > or > in Elixir)ī) 8 bits of 128 + 56 bits of 0 ( > or > in Elixir)Ī) 1 bit of 0 and 63 bits of 0 ( > or > in Elixir)ī) 1 bit of 1 and 63 bits of 0 ( > or > in Elixir)Īlso this article may be helpful especially for new developers: v Your example have the wrong sizes for the segments Anyone that suspect they have code that might be affected can turn on that warning in OTP 26.1. We also plan to introduce the same warning in OTP 26.1, but by default it will be disabled. The warning can be suppressed by matching against +0.0 instead of 0.0. To help to find code that might need to be revised, in OTP 27 there will be a new compiler warning when matching against 0.0 or comparing to that value using the =:= operator. The = operator will continue to return true for 0.0 = -0.0. When used as map keys, 0.0 and -0.0 will be considered to be distinct. Therefore, the OTP Technical Board decided that in Erlang/OTP 27, we will change +0.0 =:= -0.0 so that it will return false, and matching positive and negative 0.0 against each other will also fail. It also likely that other optimizations in the compiler could be affected and would have to be fixed in similarly cumbersome ways. To fix this optimization when =:= considers 0.0 and -0.0 to be equal would be cumbersome and could make the compiler slower. An optimization in the compiler to share identical code would consider the code for the two clauses in this function to be identical: f(_V0, _V0) ->Īnd essentially rewrite it to: f(_, _) -> We also consider it a bug, but until recently we were not sure that fixing and introducing an incompatibility would be be worth it.Ī recent bug found by erlfuzz made us reconsider. Thus, 0.0 =:= -0.0 currently returns considers this behaviour to be a bug. However, when they are matched against each other or compared using the =:= operator, they are considered to be equal. That can be seen if they are converted to binaries: 1>. Currently, the floating point numbers 0.0 and -0.0 have distinct internal representations.
