Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • bigdecimal/lib/bigdecimal/util.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

Rational

Public Instance Methods

to_d(nFig=0) click to toggle source

Converts a Rational to a BigDecimal

 
               # File bigdecimal/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