lua-users home
lua-l archive

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


> > That may not do what is expected, because it involves 
> > implementation-defined behavior:
> > 
> > 3.2.1.2 Signed and unsigned integers [...]  When an integer is
> > demoted to a signed integer with smaller size, or an unsigned
> > integer is converted to its corresponding signed integer, if the
> > value cannot be represented the result is implementation-defined.
> 
> If I remember right, you can work around this with a memcpy() from the
> unsigned variable to the signed variable.

Before trying to solve a problem, let us be sure there is a
problem. Have anyone ever used a C implementation where the conversion
from unsigned int to int did not have the "expected" behavior (keep the
bits unchanged)?

-- Roberto