diff options
Diffstat (limited to 'spec/ruby/core/float/round_spec.rb')
| -rw-r--r-- | spec/ruby/core/float/round_spec.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/ruby/core/float/round_spec.rb b/spec/ruby/core/float/round_spec.rb index 9b4c307f9d..7e8c792051 100644 --- a/spec/ruby/core/float/round_spec.rb +++ b/spec/ruby/core/float/round_spec.rb @@ -30,6 +30,11 @@ describe "Float#round" do 12.345678.round(3.999).should == 12.346 end + it "correctly rounds exact floats with a numerous digits in a fraction part" do + 0.8241000000000004.round(10).should == 0.8241 + 0.8241000000000002.round(10).should == 0.8241 + end + it "returns zero when passed a negative argument with magnitude greater than magnitude of the whole number portion of the Float" do 0.8346268.round(-1).should eql(0) end @@ -68,6 +73,10 @@ describe "Float#round" do 0.42.round(2.0**30).should == 0.42 end + it "returns rounded values for not so big argument" do + 0.42.round(2.0**23).should == 0.42 + end + it "returns big values rounded to nearest" do +2.5e20.round(-20).should eql( +3 * 10 ** 20 ) -2.5e20.round(-20).should eql( -3 * 10 ** 20 ) |
