LearnFrenzy
Sign in Take a free test

Data Types · Data Types MCQ · Question 7

Why is -1 < 1u false in C? Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 7 Back to Exercise

Why does -1 < 1u evaluate to 0 (false)?

  • A -1 is converted to unsigned (4294967295) before the comparison Correct
  • B It is a compiler bug
  • C 1u means 1 million
  • D Comparisons always return 0 for constants
Correct Answer: Option A

The usual arithmetic conversions give int and unsigned int a common type of unsigned int, so -1 becomes UINT_MAX. The same trap appears when comparing an int index with size_t from strlen().

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links