Re: [SLUG] big numbers

From: Eben King (eben1@tampabay.rr.com)
Date: Wed Mar 31 2004 - 12:27:40 EST


On Wed, 31 Mar 2004, 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.

Works for me:

[eben@pc eben]$ let foo=5678901234
[eben@pc eben]$ echo $foo
5678901234
[eben@pc eben]$ if [[ $foo -gt 5678901233 ]] ; then echo yes ; fi
yes
[eben@pc eben]$ echo $BASH_VERSION
2.05b.0(1)-release
[eben@pc eben]$ cat /etc/redhat-release
Red Hat Linux release 8.0 (Psyche)

> How do I construct a test using numbers larger than this if the program
> ignores all logic at this point?

You could split the area code from the rest, and test them separately.
Instead of "$pnum -eq $ppnum" you'd have "$pareacode -eq $ppareacode -a
$prest -eq $pprest", but I would look into the way you read or test the
numbers. Check the actual values used in the comparisons.

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
SAGITTARIUS:  All your friends are laughing behind your back... kill
them.  Take down all those naked pictures of Ernest Borgnine you've got
hanging in your den.  -- Weird Al, _Your Horoscope for Today_

----------------------------------------------------------------------- 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:45 EDT