I have one program that essentially says that: 0.34+-.01 =equals 0.35+-0.01. For a science program, that works great. These values are so close that the program figures that they are equivalent. And this is done in a DB in a very efficient way.
If you are calculating with money, eg. $15.34 vs $15.35, things get more complex. In that case what happens to the .000012345 value matters (say an interest calculation). Now things get more complex because the "rounded value" is not the only thing that matters. This "pesky whatever was left-over after the significant decimal points" matters also.
There is a thing called "BCD arithmetic". BCD means "Binary Coded Decimal". There are Perl subs that can do this type of arithmetic rather than binary, but this is a "lot slower".
However if you understand the rounding rules for Perl, you will be fine.
In reply to Re: Printf/Sprintf Behavior Change
by Marshall
in thread Printf/Sprintf Behavior Change
by stingles
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |