2018-03-04 15:09:32 +00:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require_relative 'shared/to_i'
|
2017-05-07 12:04:49 +00:00
|
|
|
|
|
|
|
describe "Float#truncate" do
|
2018-01-29 16:08:16 +00:00
|
|
|
it_behaves_like :float_to_i, :truncate
|
2017-10-28 15:15:48 +00:00
|
|
|
|
2019-04-27 18:53:23 +02:00
|
|
|
it "returns self truncated to an optionally given precision" do
|
|
|
|
2.1679.truncate(0).should eql(2)
|
|
|
|
7.1.truncate(1).should eql(7.1)
|
|
|
|
214.94.truncate(-1).should eql(210)
|
|
|
|
-1.234.truncate(2).should eql(-1.23)
|
|
|
|
5.123812.truncate(4).should eql(5.1238)
|
2017-10-28 15:15:48 +00:00
|
|
|
end
|
2017-05-07 12:04:49 +00:00
|
|
|
end
|