I am using u64 (unsigned long long int) to store the following number
val = (u64) 0x5152535455565758; - When i do print using %llu, it only print 5455565758. Few questions:
1. The reason to print this is if storage value is more than the capacity. I checked limits.h and i see ULONG64 can take up to 18446744073709551615 which in hex is FFFFFFFFFFFFFFFF. Why is my printf() not printing the entire range?
2. Does the size of data type vary on the machine architecture of gcc? (i assume architecture). Pleas throw some light on this.
3. I wrote small program as follows (please ignore line numbers), it prints correctly.
2 #include <limits.h>
5 void main()
7 unsigned long long int val = 18446744073709551615;
9 printf(" %d", sizeof(int));
10 printf("\n ULONG = %lu", ULONG_MAX);
11 printf("\n val in hex = %llx", val);
12 printf("\n val in dec = %llu\n", val);
ULONG = 18446744073709551615
val in hex = ffffffffffffffff
val in dec = 18446744073709551615
When i compile this wth -m32 flasg, ULONG values goes to half but still other prints are working fine. Am i missing something here?