-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Description
In my project I'm testing various numeric rounding methods, and I chanced upon this issue.
The failing case: 999.15.ceil(-1)
should be 1000, but it returns 1010.
RSpec.describe "Float#ceil" do
it "returns the ceiling of 999.15 correctly" do
expect(999.15.ceil).to eq 1000
expect(999.15.ceil(1)).to eq 999.2
expect(999.15.ceil(-1)).to eq 1000
end
it "returns the ceiling of 1.25 correctly" do
expect(1.25.ceil).to eq 2
expect(1.25.ceil(1)).to eq 1.3
expect(1.25.ceil(-1)).to eq 10
end
it "returns the ceiling of -999.15 correctly" do
expect(-999.15.ceil).to eq(-999)
expect(-999.15.ceil(1)).to eq(-999.1)
expect(-999.15.ceil(-1)).to eq(-990)
end
it "returns the ceiling of -1.25 correctly" do
expect(-1.25.ceil).to eq(-1)
expect(-1.25.ceil(1)).to eq(-1.2)
expect(-1.25.ceil(-1)).to eq(0)
end
end
However, only 999.15 here exhibits the issue:
1) Float#ceil returns the ceiling of 999.15 correctly
Failure/Error: expect(999.15.ceil(-1)).to eq 1000
expected: 1000
got: 1010
(compared using ==)
I haven't encountered problems with any other rounding method or arguments, but there may be more issues lurking.
Metadata
Metadata
Assignees
Labels
No labels