if then not working as expected

Everything works as expected, except for an odd problem.
In the second if-then statement:

secs4 = millis();
if( (secs4 - secs3) < charge_time) { flag_charge = yes; flag_once=yes; }  else {flag_charge=no;}
if( ( (secs4 - secs3) > 33*1000+charge_time )&& (flag_once == yes) )  { secs3 = millis(); charge_time = charge_time + 5*1000; flag_once=no; }

I want to change the number 33 to be larger (like 180). This statement works as expected for the number 33 or lower, but if I put in 34 it doesnt ever ring true. I am printing out all the values in the logic part (secs, flags, etc) and the logic says it should be true, but it doesnt do the statement.

secs are unsigned long (using millis():wink:
charge_time is long int
flags are int

thanks

Try 34*1000UL to force the result to be an unsigned long

Hey! That seems to work! thanks.

This doesnt affect numbers printed on the serial monitor.

Why does that make a difference? Does the logic perhaps need everything to be the same type?

Does the 1000UL automatically make the 33 a UL as well?

See the notes and warnings in the Arduino Reference for Integer Constants

Notes and Warnings
U & L formatters:

By default, an integer constant is treated as an int with the attendant limitations in values. To specify an integer constant with another data type, follow it with:

a 'u' or 'U' to force the constant into an unsigned data format. Example: 33u

a 'l' or 'L' to force the constant into a long data format. Example: 100000L

a 'ul' or 'UL' to force the constant into an unsigned long constant. Example: 32767ul