Jump to content

Currency: Difference between revisions

202 bytes removed ,  9 months ago
m
→‎{{header|Phix}}: mpfr_get_fixed now ok.
m (→‎{{header|Phix}}: marked incorrect)
m (→‎{{header|Phix}}: mpfr_get_fixed now ok.)
Line 1,543:
 
=={{header|Phix}}==
{{incorrect|Phix|seems I messed up mpfr_get_fixed, bear with, works on 1.0.1}}
{{libheader|Phix/mpfr}}
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #0080807060A8;">withrequires</span><span style="color: #0000FF;">(</span><span style="color: #008080008000;">javascript_semantics"1.0.4"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (mpfr_get_fixed() busted in 1.0.2|3)</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.0"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- (mpfr_set_default_prec[ision] has been renamed)</span>
<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: #7060A8;">mpfr_set_default_precision</span><span style="color: #0000FF;">(-</span><span style="color: #000000;">20</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- ensure accuracy to at least 20 d.p.</span>
Line 1,573 ⟶ 1,571:
=== 64 bit ===
As it happens, 64-bit Phix uses 80-bit floats for atoms, which actually have just enough accuracy for this task:
<!--<syntaxhighlight lang="phix">(notonline)-->
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #000000;">64</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">total_price</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">4000000000000000</span><span style="color: #0000FF;">*</span><span style="color: #000000;">5.5</span><span style="color: #0000FF;">+</span><span style="color: #000000;">2.86</span><span style="color: #0000FF;">*</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span>
7,818

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.