Round a BigDecimal : BigDecimal « Number « Ruby






Round a BigDecimal


require 'bigdecimal'
require 'bigdecimal/math'
include BigMath

two = BigDecimal("2")
BigMath::sqrt(two, 10).round(10).to_s("F")
# => "1.4142135624"

 








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.Add value to BigDecimal
10.Get the square root for a BigDecimal
11.PI in BigDecimal