One Big Number That’s Not Big Enough

By | November 27, 2012

32-bit systems pose an interesting problem because of some of its limitations. These systems are only capable of handling an integer that is  2^{63}-1 = 2147483647.   That is a fairly large number but it just not large enough.  That is particularly true if that number is a phone number (e.g. (214)748-3647).  As you can see there would be a large block of numbers that would cause problems.  In other words a phone number is not an integer and should not be cast as an integer, ever!  Normally on 32-bit systems if an integer exceeds that number it will either kindly return an error or it will send you back in time to the year 1901.  Neither one of those options are very good.  The solution: upgrade to a 64-bit system.  That will allow for a maximum integer of 9,223,372,036,854,775,807.  A 64-bit system will be good for another 292 million years.  The time solution is then solved.  However, it’s not out of the question that there could be a scenario when a researcher will exceed 9.2 quintillion.  This could be the case when dealing with large data mining and trying to analyze something like each grain of sand on a beach.  But I guess then it’s time to upgrade again to something bigger.

Note that when dealing with numbers and computers they normally begin at 0.  So at index 31 you have actually reach the 32nd position and therefore a 32-bit system.  Likewise, 2^{63}-1 = 9223372036854775807.

If you’re not certain then you can quickly find out what the maximum allowable integer by using any of the following lines of code.

In R you can identify the maximum integer:

.Machine$integer.max

In Perl you can identify dates that go back on time:


#!/usr/local/bin/perl

use POSIX;
$ENV{'TZ'} = "GMT";

for ($clock = 2147483641; $clock < 2147483651; $clock++) {
print ctime($clock);
}

In PHP this is the same as the Perl script:

<?php
date_default_timezone_set('UTC');for ($clock = 2147483641; $clock < 2147483651; $clock++) {
echo 'Date: '. date('Y-m-d h:m:s', $clock) ."\n";
}
Category: Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *