cpp-best-practices / cppbestpractices

Collaborative Collection of C++ Best Practices. This online resource is part of Jason Turner's collection of C++ Best Practices resources. See README.md for more information.
Other
8.02k stars 876 forks source link

Underflow / overflow terms are used incorrectly #108

Open Xeverous opened 5 years ago

Xeverous commented 5 years ago

03-Style - line 368

The text mentions "integer underflow". There is no such thing. Underflow (that is, truncation to zero) happens only for floating point types.

https://stackoverflow.com/questions/6360049/what-are-arithmetic-underflow-and-overflow-in-c

maz3max commented 5 years ago

Curious. I always thought integer underflow meant passing the lowest representable number. Not sure if I am too happy with calling it integer overflow or integer wrap-around instead.

Xeverous commented 5 years ago

Think of overflow as an absolute value that is too large to fit inside.