LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Handling very large integers in C: which data type? (https://www.linuxquestions.org/questions/programming-9/handling-very-large-integers-in-c-which-data-type-763549/)

Completely Clueless 10-21-2009 05:56 PM

Handling very large integers in C: which data type?
 
Hi all

I've reached a point in this program I'm writing where I need to deal with an integer that's unusually large: 1.8x10^19. I can't find any data type capable of handling more than a couple of gig. What can I use that will handle it and what is the corresponding printf format (%d% %lf% etc.)?

Thanks!

neonsignal 10-21-2009 06:08 PM

You can use long long int and unsigned long long int for integers of at least 64 bits, though I should note that the value you are dealing with is the maximum 64 bit unsigned value.

These can be printed using '%lld' and '%llu'.

If you need longer integers than 64 bits, you should look at using an arbitrary precision maths library.

Completely Clueless 10-21-2009 06:14 PM

[QUOTE=neonsignal;3727797]You can use long long int and unsigned long long int for integers of at least 64 bits, though I should note that the value you are dealing with is the maximum 64 bit unsigned value.

These can be printed using '%lld' and '%llu'.

Hey thanks, buddy.


All times are GMT -5. The time now is 04:44 AM.