# Thread: Calculating : high numbers

1. ## Calculating : high numbers

Hello, I have written a small application in Borland C++ Builder 6.0 and I would like to ask whether you know about some way of calculating with numbers higher than when calculating with unsigned int. Thank you...

( I was actually calculating Pascal's triangle nad I could have got beyond the line of about 34 because of this limit... )

2. It's machine specific.

C++ implementation states that ints are no less than 16 bits and longs no less then 32 bits. Most 32 bit machines have both int and long defined as 32 bits.

You can easily test this...

Code:
```    int integer;
long longer;

cout << "\n" << sizeof(integer) << "\t" << sizeof(longer) << endl;```
Most probably you will have a "4 4" output. Which means they are both 4 bytes long, or 32 Bits (1 byte equals 8 bits), also known as word.

As such you are left with the floating point types. float, double and long double.

float is bad for what you want. It is also 4 bytes long and as such offers only 6 significant digits (just like an int).

double is what people most usually fall in love with. It offers 10 precision digits. so you can have a number like 4,567,653,421.

long double is not supported on most 32 bit machines. It's sizeof() on my machine is the same as double. 8 bytes (or 64bits, or 2 words).

So, to say what I should have said in the very beginning and have spared you all this nonsense, go with double.

3. Use a library, eg
http://www.swox.com/gmp/

4. ( I was actually calculating Pascal's triangle nad I could have got beyond the line of about 34 because of this limit... )
If this is the case, then you're only using addition, and it would be relatively easy to store a number in a string and perform addition yourself, digit by digit.
double ... offers 10 precision digits.
Actually, a float must be at least 4 bytes (which is about 7 digits), and a double must be at least as large as a float (but it doesn't have to be any larger). Most 32-bit machines use an 8 bytes double (which is about 15 digits). I don't know where you got 10 from.

5. >> Most 32-bit machines use an 8 bytes double (which is about 15 digits). I don't know where you got 10 from.
Maybe a double on his machine is not 8 bytes long. Simple as that, though it might have been bad for Mario to impose his system's specifics as standards.

6. To get 10 digits a variable would have to be from 30 to 33 bits for an integral number. I don't know how big a floating-point variable would be; maybe about 6 bytes. Perhaps on his machine a double is 10 digits, but I doubt it.

Either way, you're right, his computer should not be taken as the standard.

7. No, it's not. It's the typical 8 bytes. It was my inferior math skills that failed on me

I apologize for the mistake.

8. You can try unsigned long long; in some implementations it's a double int size, which will reach to 20 digits in your typical 32-bit machine.

But yes, Salem is right. If you want HUGE numbers, Google up "arbitrary precision C integer library".

9. ## Thank all of you...

All of you have my thanks

10. Code:
```Posted by Mario.F
Which means they are both 4 bytes long
or 32 Bits (1 byte equals 8 bits), also known as word```
No,one word is equal to 2 bytes