Overflow in serial.print

Dear friends,
L faced a strange problem in Arduino, and at the end I find that

Serial.println(1*60*1000);

prints :
-5536
I find this happens for all answers greater than 32,767 which is the MAX range of "int" variable !
what the problem ?
and how can I solve it ?

try
Serial.println(1ul*60*1000);
to make it a unsigned long

1 Like
Serial.println(1 * 60 * 1000UL);
1 Like

Fixed.

1 Like

Great !
You solve the problem,
Thanks a lot

BTW this is nothing to do with print. Its because ints are 16 bit unless you cast to long.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.