Class: Float
Instance Method Summary collapse
-
#to_d(precision = Float::DIG) ⇒ Object
call-seq: float.to_d -> bigdecimal float.to_d(precision) -> bigdecimal.
Methods inherited from Numeric
Instance Method Details
#to_d(precision = Float::DIG) ⇒ Object
call-seq: float.to_d -> bigdecimal float.to_d(precision) -> bigdecimal
Returns the value of +float+ as a BigDecimal. The +precision+ parameter is used to determine the number of significant digits for the result (the default is Float::DIG).
require 'bigdecimal'
require 'bigdecimal/util'
0.5.to_d # => 0.5e0
1.234.to_d(2) # => 0.12e1
See also BigDecimal::new.
47 48 49 |
# File 'opal/stdlib/bigdecimal/util.rb', line 47 def to_d(precision = Float::DIG) BigDecimal(self, precision) end |