Interchanging HIGH/LOW with true/false

michinyon:
Some people advocate writing code like

boolean state = ( HIGH == digitalRead(3) )

The reason to do this, is that you will get a compiler error if you type the wrong number of equals signs.

Personally I err on the side of extra brackets. Yes, it may look a little more crowded, but you can then be 100% certain what order things are going to happen in. Some of the order of precedences can be a little grey - if you have two operators that have the same order of precedence, which one will happen first? And can you remember the order of precedence of ALL the operators off the top of your head? Thought not. I have a good memory, and I can't - only that * and / happen before - and + (as taught in maths lessons when you're 6). So, add brackets to make it explicit. Assembly doesn't use brackets, so it shouldn't make the slightest bit of difference to the quality of the resultant code, but it might make all the difference to your calculations.