|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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.
|
|
#2
|
|||
|
|||
|
perldoc -f printf
printf("%.f2n",$var); Try that or something like it. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
depends how accurate you want to be I guess!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > rounding numbers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|