Go Down

Topic: Case statement using array, help with syntax? # (Read 424 times) previous topic - next topic


Also, is it possible to have an 'or' within the case statement?
such as :

case 0b00010000 || 0b00001000:

i don't think this is correct though, because when i try it i get a duplicate case value error.
It apparently equals this one:   

case 0b00000001:


You should use bitwise OR | , not logical OR ||
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


But that combine the values into 0b00011000, so now both 0b00010000 ans 0b00001000 are no longer defined if those happen to be the values.


case 0b00010000 || 0b00001000:  // logical OR

is allowed

case 0b00010000 | 0b00001000:  // bitwise OR


as long as it can be calculated compile time (it should be a constant-expression)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up