diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-29 09:09:33 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-06-29 09:09:33 +0000 |
commit | 60bf66e0cd2c9f519f7dfb27eca134b86ea5dd8b (patch) | |
tree | dcc53a834964d3813864acd28a1cecd6777d74d2 /ext/bigdecimal/lib/bigdecimal/util.rb | |
parent | 0c11152794d4f07970a5c36981e95eb176d5fdc8 (diff) |
* ext/bigdecimal/bigdecimal.c: add RDoc document. a patch from
mathew <meta at pobox.com>. [ruby-core:07050]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal/lib/bigdecimal/util.rb')
-rw-r--r-- | ext/bigdecimal/lib/bigdecimal/util.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb index 1f8d6c7a49..2c17aa6b8e 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 |