|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: Re: Re: Re: Filthy Floatsby TheoPetersen (Priest) |
| on Jul 16, 2001 at 21:09 UTC ( #97091=note: print w/ replies, xml ) | Need Help?? |
|
Perl does lots of magic, especially in the way it handles scalars as strings, integers and floats simultaneously. In your case, the value is being handled as a string until you force Perl to treat it as a number (by using it in a multiplication). The result is a floating point value, subject to the inaccuracies described elsewhere. If it comes up with a seemingly exact value sometimes, well, welcome to the mystery :) I take it the issue here is that you want a leading zero, or some other normalization? If so, then use sprintf to enforce the format you want. Try <%=sprintf("%1.2f",$target)%> for instance.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||