Variable size/Set: Difference between revisions
m
→{{header|Phix}}: made p2js compatible
(Replaced the example with a more comprehensive text.) |
m (→{{header|Phix}}: made p2js compatible) |
||
Line 424:
When using mprf.e (aka gmp), variables can have any precision required, up to available memory.<br>
mpz (integer) variables automatically grow as needed but can optionally be initialised with a minimum bitcount to avoid later reallocations.<br>
mpfr (floating point) variables require the precision to be explicitly specified in binary bits, for example if you want PI to
{{libheader|Phix/mpfr}}
<!--<lang Phix>(phixonline)-->
<span style="color: #008080;">
<span style="color: #7060A8;">
<span style="color: #008080;">include</span> <span style="color: #004080;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #004080;">mpfr</span> <span style="color: #000000;">pi</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mpfr_init</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">121</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- 120 dp, +1 for the "3."</span>
<span style="color: #7060A8;">mpfr_const_pi</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">
<!--</lang>-->
|