mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): fix the number
of figures. Patch by Vipul A M <vipulnsward@gmail.com>. https://github.com/ruby/ruby/pull/323 fix GH-323 * test/bigdecimal/test_bigdecimal_util.rb: fix for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dd87e46310
commit
1699396fe5
3 changed files with 13 additions and 4 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Jun 4 15:30:00 2013 Kenta Murata <mrkn@cookpad.com>
|
||||
|
||||
* ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): fix the number
|
||||
of figures. Patch by Vipul A M <vipulnsward@gmail.com>.
|
||||
https://github.com/ruby/ruby/pull/323 fix GH-323
|
||||
|
||||
* test/bigdecimal/test_bigdecimal_util.rb: fix for the above change.
|
||||
|
||||
Tue Jun 4 00:44:27 2013 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* test/fileutils/test_fileutils.rb (TestFileUtils#test_mkdir): add
|
||||
|
|
|
@ -28,7 +28,7 @@ class Float < Numeric
|
|||
# # => #<BigDecimal:1dc69e0,'0.5E0',9(18)>
|
||||
#
|
||||
def to_d(precision=nil)
|
||||
BigDecimal(self, precision || Float::DIG+1)
|
||||
BigDecimal(self, precision || Float::DIG)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ class TestBigDecimalUtil < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_Float_to_d_without_precision
|
||||
delta = 1.0/10**(Float::DIG + 1)
|
||||
assert_in_delta(BigDecimal(0.5, Float::DIG+1), 0.5.to_d, delta)
|
||||
assert_in_delta(BigDecimal(355.0/113.0, Float::DIG+1), (355.0/113.0).to_d, delta)
|
||||
delta = 1.0/10**(Float::DIG)
|
||||
assert_in_delta(BigDecimal(0.5, Float::DIG), 0.5.to_d, delta)
|
||||
assert_in_delta(BigDecimal(355.0/113.0, Float::DIG), (355.0/113.0).to_d, delta)
|
||||
assert_equal(9.05.to_d.to_s('F'), "9.05")
|
||||
end
|
||||
|
||||
def test_Float_to_d_with_precision
|
||||
|
|
Loading…
Reference in a new issue