Is there a logical equivalent to:
if(byte != 0x00 || byte != 0xFF)
if(byte != 0x00 && byte != 0xFF)
I’m at my program memory limit and can use every optimalisation 🙂
To explain with words, can you check with a logic function if all bits are same (so all 0 or all 1)?
Thanks!
Assuming that
bytehas an unsigned 8-bit type [Edit: and assuming you meant&&, not||], you could try:Obviously it’s not possible to say whether this will produce smaller code, you just have to try it and see. No doubt other people can come up with other logically-equivalent expressions.
You can also look at what your compiler has produced, and if you suspect that your compiler’s optimization isn’t very good look at what other, better compilers produce. That might give you ideas for other expressions that are logically equivalent.