# Thread: Using very big numbers, long isn't enough

1. ## Using very big numbers, long isn't enough

I am trying to do calculations with very big numbers. In my calculation, for instance, the faculty of 64 is to be included in a function, and that is a very big number: 1,2688693218588416410343338933516e+89.

My program doesn't seem to work properly after around the faculty of 30. I first used int in my functions but then I tried to replace them with long. This didn't help, so I'm suspecting that using long still isn't enough. Is there a way I can handle even bigger numbers? Is there an absolute limit to the size of numbers a program can handle?

2. >Is there an absolute limit to the size of numbers a program can handle?

with standard c/c++ data types - yes

http://cboard.cprogramming.com/showt...ht=big+numbers

3. Thanks for the thread misplaced. I think it is a bit too complicated for me as I am more of a novice. I tried to use the code suggested by SangDrax but it didn't seem to compile correctly. I don't have the time to dig through all of this theory of how to write the code that handles big numbers for now. I am just in the need for handling big numbers which in itself is part of a function which is only a small part of a big project that I want to accomplish. If I went through it, perhaps I would learn more, but it would get me more away from my main target and I don't want that. I know I should also have searched for similar posts myself but I thought that too would take too much time. I am simply in the need of clear answers, if there are any.

So, can anyone suggest me the most simple way to handle very big (perhaps even infinitely big) numbers?

- Thanks, Zewu

4. lol, if your dealing with numbers like that, then buy one of those mainframes that can work out numbers like pi to 6th trillion decimal place or something, what are you working out that is that big any way?

5. Seriously, that number I posted can be handled in Windows' own calculator so I think handling it on a computer shouldn't be too difficult.

Sorry for my impatience, I have now searched a few threads and come acroos something called GPU. I have read their introduction of it and I understand it is used for calculating big numbers. I don't know how to use it though =/

6. The double datatype may be of use to you, as it stores an exponent. This means that not all digits can be accurately kept, but for the purposes of calculation it should work OK for large numbers.

If you need something that handles larger numbers, maybe Lucky's code can help you:

Otherwise, there's a large number library somewhere, maybe that was GPU.

7. - Scientific notation is good. How do you think Mr. Avagrado writes his number, hmm?
- __int64 is good. It can hold over 18 quintillion values.
- String parsed into an int is good.

8. Perhaps you meant GMP?

9. Yes, GMP was it. Unfortunately, I am unsure of how to use it.

10. There's plenty of documentation on the site.