I need to set all bits in a byte high if any of its bits are high. If none of them is high, all bits should be low.
So if the byte is 0000 1000
it should be set to 1111 1111
and if it is0000 0000
, it should just stay 0000 0000
.
How would i go about doing that without having to use if statements?
I already tried to do this with bitwise operators, but i couldn't quite figure out how to do this.
I also searched on the internet (also Stackoverflow) on how to do this, but i didn't find anything.