Closed Solved

Help with syntax

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

Could someone explain what is happening here?

X is a bit
Y is a byte
3 answers Last reply Best Answer
More about help syntax
  1. Best answer
    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.
  2. Best answer selected by bsnowman17.
  3. This topic has been closed by Area51reopened
Ask a new question

Read More

Programming Apps