i have written a script that does some price calculations based on input thru drop down menus (CGI). It all works, but I am running into problems maintaining the correct number of significant digits in calculations.
for example, trailing zeros are just obliterated, eg
2*120.00 = 240
and decimal calculations often end up with 4 or 5 trailing decimals. is there an easy way to specify 2 trailing decimal places? or am i relegated to the following ugly hacks ...
much thanks,if ($price !~ /\./) { $price .= ".00"; } else { $price =~ s/(\d*?\.\d\d).*/$1/; }
In reply to significant digits in computations by daemonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |