[PATCH] udhcpd: Handle auto_time timeout overflow

Rich Felker dalias at libc.org
Wed Jan 28 02:51:43 UTC 2015


On Tue, Jan 27, 2015 at 04:51:33PM -0500, Cathey, Jim wrote:
> At the bottom, some of C's arithmetical rules
> are 'stupid'.  Especially as regards type
> promotion.  At least they're well-defined.

No, unsigned types are just modular arithmetic. There's nothing
'stupid' or unexpected about how they behave unless you're not aware
of that, at least not any more stupid than = and == (and even === in
some langs :) having different meanings or left-shifting "cout" in
C++...

> Absolutely true in a mathematical sense is that
> the difference between two unsigned numbers is
> SIGNED!

It depends on what number system you're working in. Objects of a fixed
size cannot represent the integers so you have to either pick a number
system that can be represented (C's unsigned types) or work with an
approximation of the integers (C's signed types).

> But that's not what C does.  You can get
> around this, easy enough, but you do have to
> understand exactly what is going on.  It helps
> if you are working on a 2's-complement machine.

Twos complement is irrelevant to the operation of unsigned arithmetic.

Rich


More information about the busybox mailing list