Add value to BigDecimal : BigDecimal « Number « Ruby
- Ruby
- Number
- BigDecimal
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