зеркало из https://github.com/github/ruby.git
* 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:
Родитель
dd87e46310
Коммит
1699396fe5
|
@ -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>
|
Tue Jun 4 00:44:27 2013 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||||
|
|
||||||
* test/fileutils/test_fileutils.rb (TestFileUtils#test_mkdir): add
|
* test/fileutils/test_fileutils.rb (TestFileUtils#test_mkdir): add
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Float < Numeric
|
||||||
# # => #<BigDecimal:1dc69e0,'0.5E0',9(18)>
|
# # => #<BigDecimal:1dc69e0,'0.5E0',9(18)>
|
||||||
#
|
#
|
||||||
def to_d(precision=nil)
|
def to_d(precision=nil)
|
||||||
BigDecimal(self, precision || Float::DIG+1)
|
BigDecimal(self, precision || Float::DIG)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,10 @@ class TestBigDecimalUtil < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_Float_to_d_without_precision
|
def test_Float_to_d_without_precision
|
||||||
delta = 1.0/10**(Float::DIG + 1)
|
delta = 1.0/10**(Float::DIG)
|
||||||
assert_in_delta(BigDecimal(0.5, Float::DIG+1), 0.5.to_d, delta)
|
assert_in_delta(BigDecimal(0.5, Float::DIG), 0.5.to_d, delta)
|
||||||
assert_in_delta(BigDecimal(355.0/113.0, Float::DIG+1), (355.0/113.0).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
|
end
|
||||||
|
|
||||||
def test_Float_to_d_with_precision
|
def test_Float_to_d_with_precision
|
||||||
|
|
Загрузка…
Ссылка в новой задаче