What is “int i = 1;Why (i >= 60 * 60 * 1000 / 1 * 1000)” true?

All operators on ints return int. So yes, 60 * 60 * 1000 / 1 * 1000 - 1 is an int. But the expected result of 3599999999 is too big for an int, so the expression actually evaluates to -694967297 (assuming 32-bit int and two’s complement).

This doesn’t happen with a literal 3600000000 because integer literals larger than INT_MAX are of a type that can hold the full value.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)