In the code below, I multiplied 0xffffffff
by 2 for an unsigned int
(32bit) and stored it in a unsigned long long
(64bit). Why don't I get the actual output which is 8589934588
. Instead I get 4294967294
.
Thanks in advance.
OUTPUT:
Sizeof i=4
Sizeof J=8
2xi=4294967292
/* Code starts here */
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
unsigned int i=4294967294;
unsigned long long j=i*2;
printf("Sizeof i=%d\n", sizeof(i));
printf("Sizeof J=%d\n", sizeof(j));
printf("2xi=%llu\n", j);
return 0;
}