Use of long long int
Hi,
I'm pretty new to C coding, and I'm trying to use long long (64-bit) integers. I ran the following test program on z/OS (under USS), and on Windows 2000, but I don't understand the results:
Does anyone have an idea why the HEX print only prints the content of the first 4 bytes? Or why on Windows, the DECIMAL print produces a negative?
I think I understand the result of the BYTE print, with Windows being a little Endian, and so the entire value is stored in reverse byte order..
Test program:
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
unsigned long long juul = 123456789012345678LL;
unsigned char *pjuul;
int i;
printf("juuld: %lld\n",juul);
printf("juulx: %016X\n",juul);
pjuul = (char *) &juul;
printf("juulb: ");
for (i = 0;i < 8; i++) printf("%02X",*(pjuul + i));
printf("\n");
system("PAUSE");
exit (0);
}
/* PRODUCES on z/OS: on Windows:
juuld: 123456789012345678 -1506741426
juulx: 0000000001B69B4B 00000000A630F34E
juulb: 01B69B4BA630F34E 4EF330A64B9BB601
AND ACCORDING TO THE CALCULATOR, THIS LAST ONE IS CORRECT
*/
Thanks beforehand,
Juul
|