[EMAIL PROTECTED] said:

> 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.

Why not?  Seems like the perfect solution to me.

>                                              Is there a better way to
> convert to string?

That depends on your definition of better.

$ perl -le '$# = "%.2f"; print 9'
9.00

But $# is deprecated, so don't do that.

$ perl -le '$f = "9.00"; $z = $f; print $z'
9.00

> $z=itoa($f);
> print $z       #result 9.00
> $z=itoa($fx);
> print $z       #result 9.25
>
> sub itoa { return sprintf("%.2f", $_[0]); }

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


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

Reply via email to