I am using cc compiler on AIX 6.1 (Unix)
#include<stdio.h>
int main()
{
long long var;
scanf("%lld",&var);
printf("%lld",var);
return 0;
}
/* When I enter 16 digit number for above code its working*/
========================================
But I am not sure why below code is not showing correct value
#include<stdio.h>
int main()
{
long long var=1234567890123456;
printf("%lld",var);
return 0;
}
Please Help?
As @rici points out, the problem is with the
var
assignment.1234567890123456
was too large forint
andunsigned
in OP environment. To specify higher values, use the desire suffix.I suspect
1015724736
was printed out by the OP originally as 1234567890123456 % 4294967296. 4294967296 being the assumed range of of OP'sunsigned
( 0 to 4294967295).