summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/lib/bigdecimal/util.rb
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2021-01-13 10:28:23 +0900
committerKenta Murata <mrkn@mrkn.jp>2021-01-13 11:49:18 +0900
commita5b4b806de3b130348a92aa3306fbb9318efb762 (patch)
treef4786635a2c3ba9b7c98588542f60264add5b70d /ext/bigdecimal/lib/bigdecimal/util.rb
parent30f13164011dd876fd95a0e3fcd7c1224c4e04b5 (diff)
[ruby/bigdecimal] Allow digits=0 in BigDecimal(flt) and Float#to_d
Using dtoa of mode=0, we can determine the number of digits in decimal that is necessary to represent the given Float number without errors. This change permits digits=0 in BigDecimal(flt) and Float#to_d, and these methods use dtoa of mode=0 when the given digits is 0. Internal implicit conversion from Float also uses digits=0. [Fix GH-70] https://github.com/ruby/bigdecimal/commit/2dbe170e35
Diffstat (limited to 'ext/bigdecimal/lib/bigdecimal/util.rb')
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index 00a3e967bd..cb645d2a71 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -43,7 +43,7 @@ class Float < Numeric
#
# See also BigDecimal::new.
#
- def to_d(precision=Float::DIG+1)
+ def to_d(precision=0)
BigDecimal(self, precision)
end
end