Sign in with
Sign up | Sign in
Your question
Closed

Help with syntax

Last response: in Applications
Share
July 7, 2011 10:16:59 PM

bit_X = ((byte_Y & 0x80) ? 1 : 0);

Could someone explain what is happening here?

X is a bit
Y is a byte

More about : syntax

Best solution

a b L Programming
July 8, 2011 6:10:44 AM
Share

The expression on the right tests whether the leftmost bit of byte_Y is set. If so it sets bit_X to 1, otherwise it sets it to 0.

byte_Y & 0x80

Is the test (0x80 is 10000000 in binary).

(A ? 1 : 0)

Is the conditional.
July 8, 2011 6:21:37 AM

Best answer selected by bsnowman17.
July 8, 2011 3:04:40 PM

This topic has been closed by Area51reopened
!