December 4th, 1999, 12:46 PM
-
anyone know how to round unsing perl. I need to truncate my price to the nearest cent. I need to format the output as a dollar price. I know how to add the dollar sign, I need to make it so I always have two decimal places.
December 7th, 1999, 05:13 AM
-
perldoc -f printf
printf("%.f2n",$var);
Try that or something like it.
December 16th, 1999, 05:23 AM
-
I have a Best way in which u will get acrute result:
I have used some thing like this
Connect to any backend database for Eg ORACLE, use this Statement
"Select round($varname) from dual"
and then fetch the row.
you will get Proper result.
The other way is to use MATH Module
Available with perl check in lib directory.
I think this will help u
------------------
Ajay Lulia.
December 22nd, 1999, 09:20 PM
-
got it working.
$formattedTotal=sprintf("$%.2f",$totalPX);
that did the trick. It added a $ to the front and truncated to the nearest cent.
thanks for your help everyone.
December 28th, 1999, 01:38 PM
-
depends how accurate you want to be I guess!