123456789_123456789_123456789_123456789_123456789_

Class: Rational

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Numeric
Instance Chain:
self, ::Numeric
Inherits: Numeric
Defined in: ext/bigdecimal/lib/bigdecimal/util.rb

Instance Method Summary

Instance Method Details

#to_d(precision) ⇒ bigdecimal

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.

[ GitHub ]

  
# File 'ext/bigdecimal/lib/bigdecimal/util.rb', line 126

def to_d(precision)
  BigDecimal(self, precision)
end