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! |
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. |
[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. |