demos/perl ~0 versus ULONG_MAX

Kevin Ryde user42 at
Mon Dec 22 08:45:30 CET 2003

In the demos/perl module, scan0 and scan1 have been described as
returning ULONG_MAX which can be obtained in perl as "~0".

Unfortunately in perl 5.005 on alpha, this is not true, ULONG_MAX is
64-bits but ~0 is 32-bits.

The choice is between changing the code to be ~0 and describing just
that.  Or leaving the code and changing the docs to ask people to use
POSIX:ULONG_MAX() for testing the return.

Do we have any demos/perl users lurking here?  I'm guessing everybody
would have written "~0" rather than breaking out the POSIX module and
calling the ULONG_MAX function.  Unless they already struck this
problem and realized ULONG_MAX was what they needed.

I'm feeling inclined to give ~0, since its easier to write.

This is only a problem for old perl.  5.6 and up seems to have 64-bits
for ~0 (ie. all IVs), so if most people keep fairly up to date then
the issue might never arise, but good not to leave it inconsistent.

More information about the gmp-discuss mailing list