Richard said:
Is the unsigned long long primitive data type supported in ANSI
standard C?
I've tried using it a couple of times in standard C, but to no avail.
I'm using both MS VIsual C++ 6, as well as the gcc compiler that comes
with RedHat linux 9.
If not, what data type will yield the largest unsigned integer for me?
Thanks for your help,
Rich
Try this.
/*
Sizes of various things in bits..
*/
#include <stdio.h>
#include <limits.h>
int main(void) {
unsigned int a, b, c;
unsigned long long x, y, z;
c = -1;
b = 1 << (sizeof(int)*CHAR_BIT-1);
a = ~b;
z = -1;
y = 1LL << (sizeof(long long)*CHAR_BIT-1);
x = ~y;
printf("Size of void = %2lu bits\n", sizeof(void) *
CHAR_BIT);
printf("Size of char = %2lu bits\n", sizeof(char) *
CHAR_BIT);
printf("Size of short = %2lu bits\n", sizeof(short) *
CHAR_BIT);
printf("Size of int = %2lu bits\n", sizeof(int) *
CHAR_BIT);
printf("Size of long = %2lu bits\n", sizeof(long) *
CHAR_BIT);
printf("Size of long long = %2lu bits\n", sizeof(long long) *
CHAR_BIT);
printf("Size of int * = %2lu bits\n", sizeof(int *) *
CHAR_BIT);
printf("Size of char * = %2lu bits\n", sizeof(char *) *
CHAR_BIT);
printf("Size of void * = %2lu bits\n", sizeof(void *) *
CHAR_BIT);
printf("Size of float = %2lu bits\n", sizeof(float) *
CHAR_BIT);
printf("Size of double = %2lu bits\n", sizeof(double) *
CHAR_BIT);
printf("Size of long double = %2lu bits\n", sizeof(long double) *
CHAR_BIT);
printf("Max int = %11d\n", a);
printf("Min int = %11d\n", b);
printf("Max unsigned int = %11u\n", c);
printf("Max long long = %20lld\n", x);
printf("Min long long = %20lld\n", y);
printf("Max unsigned long long = %20llu\n", z);
return 0;
}