In Files

  • bigdecimal/lib/bigdecimal/util.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

Rational

Public Instance Methods

to_d(precision) → bigdecimal click to toggle source

Returns the value as a BigDecimal.

The required precision parameter is used to determine the number of significant digits for the result.

require 'bigdecimal'
require 'bigdecimal/util'

Rational(22, 7).to_d(3)   # => 0.314e1

See also BigDecimal::new.

 
               # File bigdecimal/lib/bigdecimal/util.rb, line 127
def to_d(precision)
  BigDecimal(self, precision)
end
            
There is an updated format of the API docs for this version here.