my $blah = sprintf("%.2f", 3.1415926535); print "$blah\n"; __END__ prints 3.14
Keep in mind this doesn't round, only truncates decimals. If you want the result in two different variables (for the stuff before and after the decimal), split on /\./
blokhead
In reply to Re: formatting numerical output
by blokhead
in thread formatting numerical output
by bilbozilla
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |