julia has built-in constant pi
, type irrational
.
julia> pi π = 3.1415926535897... julia> π π = 3.1415926535897... julia> typeof(pi) irrational{:π}
coming sympy, has n()
function, evaluate pi
(or other irrational
s, such e
, golden
, etc.) n digits.
in [5]: n(pi, n=50) out[5]: 3.1415926535897932384626433832795028841971693993751
is possible? assuming pi
based on mathematical definition, rather thirteen decimal places.
sure, can set bigfloat
precision , use big(π)
. note precision binary; it's counted in bits. should safe if set precision @ least log2(10) + 1
times number of digits need.
example:
julia> setprecision(bigfloat, 2000) @printf "%.200f" big(π) end 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196
here i've set precision little higher needs 200 digits.
the digits computed in gnu mpfr library.
Comments
Post a Comment