I have a problem while using the printf
function to print values of type unsigned long long int
I have no idea what's wrong. I'm using Dev-Cpp 4.9.9.2 and Visual Studio 2010 Professional (I know that it's not C compiler, but anyway, wanted to try) on Windows 7 Professional 64-bit. For displaying, I used %llu
modifier (according to How do you printf an unsigned long long int(the format specifier for unsigned long long int)?) but I also tried I64d with no effect...
Firstly, I just wanted to print minimum and maximum value of unsigned long long int
(using ULONG_MAX
from limits.h
)
printf("unsigned long long int: \n%llu to %llu \n\n", 0, ULONG_MAX);
Returns:
unsigned long long int: 18446744069414584320 to 1580552164021 (Dev-Cpp)
unsigned long long int: 18446744069414584320 to 0 (Visual Studio)
Then I tried to using printf
to print two zeros
printf("unsigned long long int: \n%llu to %llu \n\n", 0, 0);
Returns:
unsigned long long int: 0 to 1580552164021 (Dev-Cpp)
unsigned long long int: 0 to 0 (Visual Studio)
Also tried two ULONG_MAX
values
printf("unsigned long long int: \n%llu to %llu \n\n", ULONG_MAX, ULONG_MAX);
Returns:
unsigned long long int: 18446744073709551615 to 1580552164021 (Dev-Cpp)
unsigned long long int: 18446744073709551615 to 0 (Visual Studio)
Why does it behave like that? Could you explain it to me?