IF && operators

Hi,

I can't get this to run properly, It only uses the "else" and never divide the "sysregval" with 10 even though NUM_SYSTEMREGS is within values.

1-6, 8-18, 27-48, then it should divide value with 10. Otherwise no.

What do I do wrong? :slight_smile:

            if( (NUM_SYSTEMREGS >= 1) && (NUM_SYSTEMREGS <= 6))
            {
              Serial.print( (float)sysregval/10.0, 1 );       //<-- change to display oC
              Serial.println( " C" );
            }
 
            else if( (NUM_SYSTEMREGS >= 8) && (NUM_SYSTEMREGS <= 18))
            {
              Serial.print( (float)sysregval/10.0, 1 );       //<-- change to display oC
              Serial.println( " C" );
            }
            else if( (NUM_SYSTEMREGS >= 27) && (NUM_SYSTEMREGS <= 48))
            {
              Serial.print( (float)sysregval/10.0, 1 );       //<-- change to display oC
              Serial.println( " C" );
            }
            else
            {
              Serial.println( sysregval );       //<-- change to display oC
            }

What do I do wrong? :slight_smile:

Well you only posted a snippet, there is no way to verify the variable type or it's value. If you want help you will need to provide more info.

Atleast it's possible to verify the snippet.

can't see why it's not working with that snippet.

i.e. here is 1/2 cup sugar. why did my cake fail?

Because you can't bake as I can't code :slight_smile: Easy peasy.
Well, I found my error and the problem was that I have uploaded wrong sketch to the board

Yes, and the snippet looks ok. NUM_SYSTEMREGS sounds like a #define'd constant. What value is it?

EDIT: forget it!