note
syphilis
<I>What can I do to prevent this kind of rounding error ?</I>
<br><br>Update: This is for the main part a rehash of what [haukex] had posted 5 hours earlier ... something I had failed to observe first time round.
<br><br>You could change the last line of your code from:
<br><br><c>print "$_ => $x\n";</c><br>to<br><c>printf "$_ => %.2f\n", $x;
</c>
<br>Any module that does decimal (as opposed to binary) arithmetic would also provide correct results.
<br> These modules include Math::BigFloat, Math::Decimal and Math::Decimal64.
<br><br>Cheers,<br>Rob
1206513
1206513