c++ - Why is long long value not printed correctly? -
why long long value not printed expect in following code snippet?
#include <stdio.h> int main() { int x = 1363177921; long long unsigned y = x * 1000000; printf("y: %llu\n", y); // why 1363177921000000 not printed? return 0; }
it's not printing that's @ fault. have integer overflow in:
long long unsigned y = x * 1000000;
change to:
long long unsigned y = x * 1000000ull;
Comments
Post a Comment