Re: [SLUG] big numbers

From: Ronan Heffernan (ronanh@auctionsolutions.com)
Date: Wed Mar 31 2004 - 12:17:44 EST


mrock wrote:

>I have a program that analyses calls to phone numbers. (yes, this is the
>same program that I have struggle with for some time now) The data file
>is sorted on phone number (area code and the number) that makes it a 10
>digit number. My comparisons fail at 2 to the 31st power. My last
>phone number that works is 2147493101. 2 to the 31st power is
>2147483648. I think this is also the 2 Gbit limit I ran into in much
>older systems. I am running RH 8.0.
>
>
>
This is probably not a 2GBit file limitation, but rather your numerical
operations are using a signed-int (on linux, gcc treats 'int' and 'long'
(and probably 'short') as 32-bits (at least this is the behavior on
32-bit architectures)). The fact that the int is 'signed' means that the
possible range of values is approximately negative 2.1 billion through
positive 2.1 billion. If you were able to tell BASH to use an 'unsigned
int' then your range of values would become zero through apprx 4.2
billion (which would still not work for you!) One thing that you might
try is to add a ".0" to the end of your phone numbers to see if BASH
will then treat them as 'float' numbers (twice the capacity?) I don't
know if BASH will do float operations with -eq -lt -gt ? Maybe try it
with a small sample file?

If BASH can not be made to use higher-capacity variable types, you could
use PERL, Python, C++, etc. (probably not the most welcome of answers.)

--ronan

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:50:31 EDT