Class: Rational
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
::Numeric
|
|
|
Instance Chain:
self,
::Numeric
|
|
| Inherits: |
Numeric
|
| Defined in: | lib/bigdecimal/util.rb |
Instance Method Summary
-
#to_d(precision) ⇒ bigdecimal
Returns the value as a
::BigDecimal.
Instance Method Details
#to_d(precision) ⇒ bigdecimal
Returns the value as a ::BigDecimal.
The precision parameter is used to determine the number of significant digits for the result. When precision is set to 0, the number of digits to represent the float being converted is determined automatically. The default precision is 0.
require 'bigdecimal'
require 'bigdecimal/util'
Rational(22, 7).to_d(3) # => 0.314e1
See also Kernel.BigDecimal.
# File 'lib/bigdecimal/util.rb', line 135
def to_d(precision=0) BigDecimal(self, precision) end