lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Without the casts, you might get signed overflow, and signed overflow
> has undefined results in C.  Real compilers take advantage of this
> during optimization (it's not just a theoretical issue), meaning that
> the result may not be what you wanted, even when the hardware itself
> uses a straightforward twos-complement representation...

Also, several CPUs have instructions that raise interruptions when they
detect overflows. Doing the arithmetic with unsigneds is a way to ensure
that the compiler will not use these instructions.

-- Roberto