News for hackers. Stuff that matters.
Re:Almost Always Unsigned by cies on Sunday January 02, 2022 @09:54AM (#29769152)
So what about an unsigned int going below zero? I think most in the comments here mean that by "underflow", but i could be mistaken (and it should correctly be called "overflow" as well).

I agree with the WP article saying integers more correctly "wrap around" (than overflow).

Re:Almost Always Unsigned by leni536 on Sunday January 02, 2022 @10:56AM (#29769728)
The C standard only calls certain integer arithmetic to "overflow" if it results in undefined behavior. In that sense undefined integer arithmetic never overflows, but they "wrap around", as the behavior is defined there.

I can't actually find a normative definition for "overflow" in the C or C++ standards, but there are sections and notes that describe this interpretation:

C++: https://eel.is/c++draft/full#basic.fundamental-note-2

C: http://web.archive.org/web/20211231011139/https://cigix.me/c...

There can be subtle differences between various definitions of "overflow", and I imagine there could be other subtly different definitions outside C and C++. But "underflow" is exclusively a floating point concept, as far as I know.