Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/elixir/lib/float.ex
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ defmodule Float do
count = count - exp + 1023

cond do
count <= 0 -> # There is no decimal precision
count <= 0 or # There is no decimal precision
(0 == exp and <<0::52>> == significant) -> #zero or minus zero
float

count >= 104 -> # Precision beyond 15 digits
Expand Down
3 changes: 3 additions & 0 deletions lib/elixir/test/elixir/float_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ defmodule FloatTest do
assert Float.ceil(0.32453e-10) === 1.0
assert Float.ceil(-0.32453e-10) === 0.0
assert Float.ceil(1.32453e-10) === 1.0
assert Float.ceil(0.0) === 0.0
end

test "ceil/2 with precision" do
Expand All @@ -94,6 +95,8 @@ defmodule FloatTest do

assert Float.ceil(12.32453e-20, 2) === 0.01
assert Float.ceil(-12.32453e-20, 2) === 0.0

assert Float.ceil(0.0, 2) === 0.0
end

test "round/2" do
Expand Down