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

Discussion

The expression n & 1 evaluates to 1 exactly when n is odd.

  • A.True
  • B.False

Answer: A

Correct answer: True

The least significant bit carries the value 1, so it is set precisely for odd numbers. Masking with 1 is therefore a faster parity test than taking the remainder, and unlike the remainder operator it behaves the same for negative values in two’s complement.

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

Post your comment

Please log in or register to post a comment.