Variable size/Set: Difference between revisions

m
→‎{{header|Phix}}: use new simplified d.p. setting
m (→‎{{header|Phix}}: use new simplified d.p. setting)
Line 412:
mpfr (floating point) variables require the precision to be explicitly specified in binary bits, for example if you want PI to 1000 decimal places:
{{libheader|mpfr}}
<lang Phix>include mpfr.e -- requires 0.8.01+
stringmpfr ninespi = repeatmpfr_init('9'0,-1001) -- 1000 --dp, +1 for the "3."
mpz ndp = mpz_init(nines) -- mpz_init(nines,3326) would be identical
integer precision = mpz_sizeinbase(ndp,2) -- 3326
mpfr pi = mpfr_init(0,precision) -- or just hard-code that 3326
mpfr_const_pi(pi)
mpfr_printf(1,"PI with 1000 decimals: %.1000RDf\n\n",pi)</lang>
7,806

edits