|
-
Jan 12th, 2004, 01:31 AM
#1
Thread Starter
Addicted Member
Calculating Prices In CGI/Perl
Hi,
I'm trying to calculate prices in CGI/Perl, but I'm having a problem with the loss of trailing zeros. ie.:
$Price1 = "1.20";
$Price2 = "1.50";
$TotalCost = $Price1 + $Price2;
'$TotalCost' would have the value of "2.7"... I want to be able to print it with a trailing zero on the end of it, so when I print it out it'll be "2.70" rather than "2.7", for example. How do I do this? I'm assuming this involves string/character checks and manipulation but I'm not sure how to go about it.
Cheers,
Git
-
Jan 12th, 2004, 05:05 AM
#2
Does Perl have a printf or pad function?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 14th, 2004, 05:42 AM
#3
Thread Starter
Addicted Member
To be honest I'm not really sure, as I'm a bit of a newbie at all the functions/etc.. Does anyone know how to do this?
Cheers,
Git
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|