num
is long
. When you compare int
with long
how x < num
, int
will advance to long
. Assuming yours num
is large enough (greater than the maximum value int
), x
will never reach it and yours x++
will be executed. At some point, the value will x
overflow and become 0
.
source
to share