http://qs321.pair.com?node_id=11118666


in reply to Re: Reliably parsing an integer (updated)
in thread Reliably parsing an integer

First of all, thanks for your quick answer.

Perl's maximum values for integers can be determined

That is brilliant, thanks.

If you want to work with integers larger than that, use Math::BigInt.

I do not really want to work with larger integers. I want to allow up to the maximum unsigned integer value in the current Perl. I would rather avoid the overhead of using Math::BigInt if I can.

To validate number formats, use Regexp::Common::number.

How are these regular expressions going to help? Say the current Perl uses 32-bit integers. How is a regular expression going to help me accept 4294967295 (UINT32_MAX) but not 4294967296 (UINT32_MAX+1)?

Say Perl automatically "upgrades" UINT64_MAX + 1 to a floating-point value, and the platform uses 64-bit integers but also 64-bit floating point values. Is that not going to lose some precision? How can I then accept exactly up to UINT64_MAX but not UINT64_MAX + 1 ?