bitwise or'ing multiple varibles

is this valid ?

byte a,b,c,z;

z = a | b | c;

I don't see any reason why not. Write a short test program and give it a try.

Try it. If successful, any 1 at a bit position in a, b, c will show up as a 1 in z.
Ex:
a = 0b00000011
b = 0b00001100
c = 0b00110000
then z = 0b00111111

Of course it is valid. I am not sure why there is any hesitation.

It is no different than

z = a|b;
z = z|c;

It would have been faster and better to test it, rather than ask the question here. Experimentation is a great way to learn. :slight_smile:

OldSteve:
It would have been faster and better to test it, rather than ask the question here. Experimentation is a great way to learn. :slight_smile:

+1

thanks all