Skip to content

Commit

Permalink
Merge pull request #260 from mikpe/fix-match-on-float-zero
Browse files Browse the repository at this point in the history
mochinum:digits/1: fix handling of -0.0 for OTP-26.1/27.0
  • Loading branch information
nickva authored Sep 22, 2023
2 parents cab4474 + 1aa9ba1 commit 97573d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mochinum.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
%% human-readable output, or compact ASCII serializations for floats.
digits(N) when is_integer(N) ->
integer_to_list(N);
digits(0.0) ->
digits(Float) when Float == 0.0 ->
"0.0";
digits(Float) ->
{Frac1, Exp1} = frexp_int(Float),
Expand Down Expand Up @@ -287,6 +287,8 @@ digits_test() ->
digits(0)),
?assertEqual("0.0",
digits(0.0)),
?assertEqual("0.0",
digits(-0.0)),
?assertEqual("1.0",
digits(1.0)),
?assertEqual("-1.0",
Expand Down

0 comments on commit 97573d2

Please sign in to comment.