lua-users home
lua-l archive

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


William Ahern <william@25thandClement.com> writes:
> Why even bother with the explicit conversions? If you're relying on
> two's-complement behavior, it's unnecessary. If you're not, it's
> insufficient. Am I missing something?

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...

-miles

-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff