Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the value of the expression 13 | 25?

  • A.29
  • B.9
  • C.20
  • D.31

Answer: B

Correct answer: 29

OR compares the two numbers bit by bit and keeps a 1 where either has one:

  13 = 0 1 1 0 1
  25 = 1 1 0 0 1
  --------------
   |  = 1 1 1 0 1

The result 11101 is \( 16 + 8 + 4 + 1 = 29 \).

A useful check: OR can never produce a value smaller than either operand, since it only ever turns bits on, so an answer below 25 would be wrong on inspection alone. That rules out 9 - which is what & gives - and 20, which is ^, without any arithmetic.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.