The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Can you see any bugs?
In perl, strings like "2e5" and "1E4" are valid integer strings. Are they being handled as you would like ? (I haven't investigated, and it depends upon how you want them to be treated.) If you want to accept them then you also have to keep in mind that if they represent values greater than ~0 or less than -(~0 >> 1) then they'll be assigned to NVs (floating point values) rather than IVs (integer value). I guess it's probably simplest if you reject them. Update, correcting an earlier incorrect update: After I wrote this post I discovered that if you assign a value like 2e5 as a bareword, you get an NV, not an IV - and I therefore thought I had made a mistake in asserting that such strings were "integer strings". However, although the barewords often assign as an NV, the above assertions seem to be correct in relation to numifying strings. It seems a bit random. We get an NV with: but an IV if we perform some arithmetic function: and, as regards what I've written above, if we numify the string we still get an IV: unless the value represented by the string is outside of the IV range:
Cheers, Rob In reply to Re^9: Reliably parsing an integer
by syphilis
|
|