PI in BigDecimal : BigDecimal « Number « Ruby






PI in BigDecimal



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


Math::PI                                    # => 3.14159265358979
Math::PI.class                              # => Float
BigDecimal.PI(1).to_s
# => "0.31415926535897932364198143965603E1"
BigDecimal.PI(20).to_s
# => "0.3141592653589793238462643383279502883919859293521427E1"

 








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.Get the square root for a BigDecimal