in reply to Re: Multiple Conditional Statements
in thread Multiple Conditional Statements
the OP didn't specify if e.g. 05.0 is identical to 5 or not - probably yesWell, OP specified "!=" operator in original post.
However, as shown below, sanitizing inputIn general case, programmer cannot control if his data is numified or no. So I don't think it's really about "sanitizing".
floats might need normalisation using sprintf...In general case, normalization for floats won't work well, example:
prints 0.5, 0.4 and 0.000000perl -e 'my ($a, $b) = (0.45000001, 0.4499999); print sprintf ("%0.1f +%0.1f %f", $a, $b, $a-$b )'
My example Re: Multiple Conditional Statements can be fixed to work with floats (but I admit it's slow).
UPD: fixed float example
|
---|
In Section
Seekers of Perl Wisdom