There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If someone should be blamed for this, it is not Perl, but c, and Perl just inherits it. If you are using languages support fixed decimal, for example COBOL or PL/SQL, then this problem disappears. Here is an example what can happen to c: (It does not give 14720)
If you really care the accuracy and precision, try Math::BigFloat. Now here is something a little bit off topic, but interesting. If you do this in c:
It produces -167772160, which is ridiculous, as c tries to interprete that piece of memory as integer, as you required. Good you are using Perl. In Perl, if you do the same thing with:
It produces 14719 (not precise, but better than c), as internally Perl does:
In reply to Re: (s)printf and rounding woes
by pg
|
|