Data Type Limit

This is a C question. I’d like to use an integer that can
go upto 100 Billion.Even if i declare an interger as a long int, it would
only allow me to go upto 4 Billion. I tried to use “unsigned long long”.
However, this doesn’t compile on the Watcom compiler on QNX 4.2.

I appreciate your suggestions.

Shashank

Shashank wrote:

This is a C question. I’d like to use an integer that can
go upto 100 Billion.Even if i declare an interger as a long int, it would
only allow me to go upto 4 Billion. I tried to use “unsigned long long”.
However, this doesn’t compile on the Watcom compiler on QNX 4.2.

I appreciate your suggestions.

Use floating point arithmetic. (double and frends)

–Armin

Shashank

Shashank <sbalijepalli@precitech.com> wrote:

This is a C question. I’d like to use an integer that can
go upto 100 Billion.Even if i declare an interger as a long int, it would
only allow me to go upto 4 Billion. I tried to use “unsigned long long”.
However, this doesn’t compile on the Watcom compiler on QNX 4.2.

We didn’t/don’t have 64-bit math support for QNX 4. At least, not
built in.

One person suggested floats, another choice is (depending on how
complex the math you want to do is) is to represent your number
with two 32-bit ints, and handle the math and display of this
number yourself.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

There are plenty of freeware libraries and C++ classes out there to handle
arbitrary long integer numbers.

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:ddfpa0$1v5$1@inn.qnx.com

Shashank <> sbalijepalli@precitech.com> > wrote:

This is a C question. I’d like to use an integer that can
go upto 100 Billion.Even if i declare an interger as a long int, it would
only allow me to go upto 4 Billion. I tried to use “unsigned long long”.
However, this doesn’t compile on the Watcom compiler on QNX 4.2.

We didn’t/don’t have 64-bit math support for QNX 4. At least, not
built in.

One person suggested floats, another choice is (depending on how
complex the math you want to do is) is to represent your number
with two 32-bit ints, and handle the math and display of this
number yourself.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

Shashank wrote:

This is a C question. I’d like to use an integer that can
go upto 100 Billion.Even if i declare an interger as a long int, it would
only allow me to go upto 4 Billion. I tried to use “unsigned long long”.
However, this doesn’t compile on the Watcom compiler on QNX 4.2.

I appreciate your suggestions.

The Python source code (double-check their open source license before
you use their code - www.python.org) has support in it for arbitrarily
large numbers:

CHerborth@qnxws7083 [501]: python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type “help”, “copyright”, “credits” or “license” for more information.

x = 100000000000
print x
100000000000
x + 1
100000000001L
x * x
10000000000000000000000L

IIRC the code wouldn’t be that hard to pull out (I seem to remember
extending it to handle 64-bit native integers or something a few years
ago), and it might be based on other free “big number” code.


Chris Herborth (cherborth@qnx.com)
Never send a monster to do the work of an evil scientist.
Monthly QNX newsletter - http://www.qnx.com/news/forms/newsletter.html