Bits and bytes- Please help.
First of all very sorry for coming up with such a vague title. I couldn't think any better title for this thread.
I have been asked to use a byte for representing 8 different channels. Every corresponding on bit indicates the channel is available. All I need to do is to find the first free channel based on the value in the byte.
if byte has the value 3 (0000 0011), I need to say 7th channel is free of usage.
if the value is 255(1111 1111), then 1st channel is free for usage .
I need to arrive at this decision ASAP, as this function is expected to be heavily used.
Looping around the bits will not be a feasible solution.
Could someone please help with this?