Add value to BigDecimal : BigDecimal « Number « Ruby






Add value to BigDecimal


require 'bigdecimal'

two_thirds = (BigDecimal("2", 13) / 3)

two_thirds.add(1, 1).to_s                  # => "0.2E1"
two_thirds.add(1, 4).to_s                  # => "0.1667E1"

 








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..to_s("F")
8.Convert BigDecimal to string
9.Round a BigDecimal
10.Get the square root for a BigDecimal
11.PI in BigDecimal