Get the square root for a BigDecimal : BigDecimal « Number « Ruby






Get the square root for a BigDecimal

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

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

 








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.Round a BigDecimal
11.PI in BigDecimal