.to_s("F") : BigDecimal « Number « Ruby






.to_s("F")


require 'bigdecimal'

(a = BigDecimal("2.01")).precs               # => [8, 8]
(b = BigDecimal("3.01")).precs               # => [8, 8]

(product = a * b).to_s("F")                  # => "6.0501"
product.precs                                # => [8, 24]

 








Related examples in the same category

1.Big decimal calculation
2.Calculation on BigDecimal in a function
3.precs of BigDecimal
4.Convert big decimal to string
5.to_f cuts numbers
6.split a big number
7.Convert BigDecimal to string
8.Add value to BigDecimal
9.Round a BigDecimal
10.Get the square root for a BigDecimal
11.PI in BigDecimal