try the sprintf

print sprint("%.02f", $f);

if I'm not rong;



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 14, 2003 10:18 AM
To: [EMAIL PROTECTED]
Subject: help float to string


Can someone help me with retaining the precisions when they are zero?

ie -

$f = 9.00
$z = $f;
print $z; #result in 9 - bad I want 9.00

$fx = 9.25
$z = $fx;
print $z; #result in 9.25 - good

I can but don't want to use a sub like itoa. Is there a better way to
convert to string?

$z=itoa($f);
print $z       #result 9.00
$z=itoa($fx);
print $z       #result 9.25

sub itoa { return sprintf("%.2f", $_[0]); }



-----------------------------------------
eMail solutions by 
http://www.swanmail.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to