File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -374,8 +374,8 @@ defmodule Float do
374
374
case rounding do
375
375
:ceil when sign === 0 -> 1 / power_of_10 ( precision )
376
376
:floor when sign === 1 -> - 1 / power_of_10 ( precision )
377
- :ceil when sign === 1 -> - 0.0
378
- :half_up when sign === 1 -> - 0.0
377
+ :ceil when sign === 1 -> minus_zero ( )
378
+ :half_up when sign === 1 -> minus_zero ( )
379
379
_ -> 0.0
380
380
end
381
381
@@ -406,7 +406,7 @@ defmodule Float do
406
406
407
407
cond do
408
408
num == 0 and sign == 1 ->
409
- - 0.0
409
+ minus_zero ( )
410
410
411
411
num == 0 ->
412
412
0.0
@@ -422,6 +422,10 @@ defmodule Float do
422
422
end
423
423
end
424
424
425
+ # Tricking the compiler to avoid this bug in versions before OTP27
426
+ # https://github.com/elixir-lang/elixir/blob/main/lib/elixir/lib/float.ex#L408-L412
427
+ defp minus_zero , do: - 0.0
428
+
425
429
defp decompose ( significant , initial ) do
426
430
decompose ( significant , 1 , 0 , initial )
427
431
end
You can’t perform that action at this time.
0 commit comments