Mega Code Archive

 
Categories / Ruby / Number
 

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"