summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/lib
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 11:30:24 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-05 11:30:24 +0000
commit2810c12a99fed7297d558d8b1aaaf755eb8b8a2d (patch)
tree03ded624e1b6eab7bcf9059c5193c25f10ee26ae /ext/bigdecimal/lib
parentae88d2fc93e887f22d025b4738ebbb00f6ae53e9 (diff)
Import bigdecimal 1.4.0.pre.20181205a
* https://github.com/ruby/bigdecimal/compare/74d25ef..v1.4.0.pre.20181205a git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/lib')
-rw-r--r--ext/bigdecimal/lib/bigdecimal/jacobian.rb3
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb30
2 files changed, 24 insertions, 9 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
index 9cad06c09b5..84c50248b70 100644
--- a/ext/bigdecimal/lib/bigdecimal/jacobian.rb
+++ b/ext/bigdecimal/lib/bigdecimal/jacobian.rb
@@ -21,6 +21,9 @@
#
# fx is f.values(x).
#
+
+require 'bigdecimal'
+
module Jacobian
module_function
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index 911fa6fe3af..88f490cb45e 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -5,6 +5,8 @@
# and provides BigDecimal#to_d and BigDecimal#to_digits.
#++
+require 'bigdecimal'
+require 'bigdecimal/util.so'
class Integer < Numeric
# call-seq:
@@ -42,8 +44,8 @@ class Float < Numeric
#
# See also BigDecimal::new.
#
- def to_d(precision=nil)
- BigDecimal(self, precision || Float::DIG)
+ def to_d(precision=Float::DIG)
+ BigDecimal(self, precision)
end
end
@@ -64,13 +66,6 @@ class String
#
# See also BigDecimal::new.
#
- def to_d
- begin
- BigDecimal(self)
- rescue ArgumentError
- BigDecimal(0)
- end
- end
end
@@ -132,3 +127,20 @@ class Rational < Numeric
BigDecimal(self, precision)
end
end
+
+
+class NilClass
+ # call-seq:
+ # nil.to_d -> bigdecimal
+ #
+ # Returns nil represented as a BigDecimal.
+ #
+ # require 'bigdecimal'
+ # require 'bigdecimal/util'
+ #
+ # nil.to_d # => 0.0
+ #
+ def to_d
+ BigDecimal(0)
+ end
+end