SOLVED Combined operators shortcuts?

C

CruelBus

Guest
I have the following in various forms all over the place:
if( DNtimer>30599 && DNtimer<31560 ){skyCOL=2;}

I tried the following:
if( 31560>DNtimer>30599 ) {skyCOL=2;}
and it doesn't seem to work.

What about:
sunrise=DNtimer>9000;
instead of:
if(DNtimer>9000){sunrise=true;}


Am I formatting these wrong or are they just not valid expressions?
 
Last edited by a moderator:

Nidoking

Member
I tried the following:
if( 31560>DNtimer>30599 ) {skyCOL=2;}
and it doesn't seem to work.
Not working is how it works. This isn't a math paper. Only one operation happens at a time, and you're comparing one of the two numbers on the end to either true or false, depending on the order of operations. (Which should be left to right, but I wouldn't rely on that.)

What about:
sunrise=DNtimer>9000;
instead of:
if(DNtimer>9000){sunrise=true;}
That syntax works just fine, but these two blocks are not equivalent. In the first case, if DNtimer is not over 9000, sunrise will be set to false. In the second case, sunrise will retain its previous value. Variables can store boolean values.
 

HalRiyami

Member
sunrise = (DNtimer > 9000) should work and would evaluate to if DNtimer > 9000 {sunrise = true} else {sunrise = false}

As for if (a<variable<b) {}, it would not work.
 
Top