in reply to Reliably parsing an integer
The results are puzzling.What the string is: 99999999999999999999 Value of $strAsInteger: 1e+20 How printf sees it: 18446744073709551615
Perl automatically upgrades large integers to floating point.
Perl's maximum values for integers can be determined as I showed in this post.
If you want to work with integers larger than that, use Math::BigInt.
To validate number formats, use Regexp::Common::number.
Update: If two integers are the same length (or are zero-padded to be the same length), Perl's string comparisons can be used.
|Replies are listed 'Best First'.|
Re^2: Reliably parsing an integer
by rdiez (Acolyte) on Jun 29, 2020 at 16:48 UTC