summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/lib/bigdecimal/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bigdecimal/lib/bigdecimal/util.rb')
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index 1f8d6c7..2c17aa6 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -1,19 +1,17 @@
#
# BigDecimal utility library.
-# ----------------------------------------------------------------------
-# Contents:
#
-# String#
-# to_d ... to BigDecimal
+# To use these functions, require 'bigdecimal/util'
+#
+# The following methods are provided to convert other types to BigDecimals:
#
-# Float#
-# to_d ... to BigDecimal
+# String#to_d -> BigDecimal
+# Float#to_d -> BigDecimal
+# Rational#to_d -> BigDecimal
#
-# BigDecimal#
-# to_r ... to Rational
+# The following method is provided to convert BigDecimals to other types:
#
-# Rational#
-# to_d ... to BigDecimal
+# BigDecimal#to_r -> Rational
#
# ----------------------------------------------------------------------
#
@@ -30,8 +28,8 @@ class String
end
class BigDecimal < Numeric
- # to "nnnnnn.mmm" form digit string
- # Use BigDecimal#to_s("F") instead.
+ # Converts a BigDecimal to a String of the form "nnnnnn.mmm".
+ # This method is deprecated; use BigDecimal#to_s("F") instead.
def to_digits
if self.nan? || self.infinite? || self.zero?
self.to_s
@@ -42,7 +40,7 @@ class BigDecimal < Numeric
end
end
- # Convert BigDecimal to Rational
+ # Converts a BigDecimal to a Rational.
def to_r
sign,digits,base,power = self.split
numerator = sign*digits.to_i
@@ -57,7 +55,7 @@ class BigDecimal < Numeric
end
class Rational < Numeric
- # Convert Rational to BigDecimal
+ # Converts a Rational to a BigDecimal
def to_d(nFig=0)
num = self.numerator.to_s
if nFig<=0