Class: Rational
- Inherits:
-
Numeric
- Object
- Numeric
- Rational
- Defined in:
- lib/bigdecimal/util.rb
Instance Method Summary collapse
-
#to_d(nFig = 0) ⇒ Object
Converts a Rational to a BigDecimal.
Instance Method Details
#to_d(nFig = 0) ⇒ Object
Converts a Rational to a BigDecimal
58 59 60 61 62 63 64 |
# File 'lib/bigdecimal/util.rb', line 58 def to_d(nFig=0) num = self.numerator.to_s if nFig<=0 nFig = BigDecimal.double_fig*2+1 end BigDecimal.new(num).div(self.denominator,nFig) end |