unsigned: A Guideline for Better Code
summary
Example compares signed -1 with unsigned 1 and prints "else: a is not less than b" because the signed value promotes and becomes large — surprising even experienced programmers. Recommendation: don't use unsigned for quantities, reserve unsigned for bitmasks, character bytes, or raw bit containers. Choose types for the operations they must support, not just range; prefer a larger signed type to avoid hidden bugs; note that size_t is unsigned for historic reasons but does not justify exposing unsigned in APIs.
AI-written summary · about
chapters (4)
related talks
57mSane and Safe C++ Class Types
46mIntegers, Floating Points or Exotic Representations ...
54mWriting C++ to Be Read
55mC++ Core and Other C++ Guidelines - The Good, the Bad, the… Questionable?
50mCore and other guidelines. The good, the bad, the... questionable?
34mHidden in Plain Sight: Corner Case Defects
59mBuilding Cpp Interfaces That Are Hard to Use Incorrectly
01h 01mSome Programming Myths Revisited
