Why 120*1000 != 120,000?

as cooldown is an int, it would not work to do

int cooldown = 1000ul;
long timerTmp = 120 * cooldown;

the maths would still be conducted as int

you need to do

int cooldown = 1000;
long timerTmp = 120ul * cooldown; // ul to force calculation using long

or store cooldown as a long

long cooldown = 1000;
long timerTmp = 120 * cooldown; // cooldown being a long, the math is done using long
1 Like