in reply to Testing For Numberness Vs Stringness
What you are seeing is the fact that Perl will happily use a stringified number as a numerified string if it makes sense to do so. That is, to Perl, '3.0' (the string) is the same numerically as 3.0 (the number). It is also true that Perl will happily stringify a number where it makes sense to do so. Where this begins to break down is when you compare the number 3.0 with the string '3.0' using a string comparison. This fails because 3.0 (the number) is actually just 3 (the number). Stringified, that is '3' (the string). When you compare '3' eq '3.0', you are going to get inequality, since as strings go, they're not the same.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Testing For Numberness Vs Stringness
by BrooklineTom (Novice) on Nov 27, 2004 at 17:35 UTC | |
by theorbtwo (Prior) on Nov 27, 2004 at 23:24 UTC | |
by BrooklineTom (Novice) on Nov 29, 2004 at 13:12 UTC |