Longer than long

Sometimes you need to use really big numbers — and 32 bits just won’t cut it.

Fortunately, the gcc compiler has this covered; its “long long” type supports signed and unsigned 64-bit integers. The difference is huge — whereas unsigned 32-bit integers are limited to 0-4,294,967,295, 64-bit integers can go all the way up to 18,446,744,073,709,551,615.

These numbers can be used in C as shown in this example:

#include <stdio.h>
int main(){

//Variable declaration
unsigned long long int myNumber = 1;
int power;

//For loop
for(power = 0; power < 63; power++){
printf(“Power: %d      Number: %llu\n”,power,myNumber);
myNumber = myNumber * 2;
}//for

return(0);

}//main()

This entry was posted in C, Coding, Linux, Math and tagged , , , , , , . Bookmark the permalink.

Leave a Reply