Marshall Clow <[EMAIL PROTECTED]> writes:

> >Not quite. The conversion from unsigned to signed int *is* well-defined.
> 
> For some implementations.

For any implementation that conforms to ANSI. Random non-conforming
implementations are out of scope.

> 
> 
> >Chapter and verse: ANSI, 3.2.1.2, lines 23-27:
...
> 
> And if the unsigned integer does not have greater size?

Next paragraph:

"When a value with integral type is demoted to an unsigned integer
with smaller size, the result is the nonnegative remainder on division
by the number one greater than the largest unsigned number that can be
represented in the type with the smaller size."

> >So an expression like "(unsigned int) 1 + -10" is officially
> >well-defined and has the value UINT_MAX - 8. 
> 
> Assuming two's-complement representation.

No, see what I wrote before. The spec requires the behaviour of
two's-complement representation even for systems with other underlying
representations. From the Rationale for the same section:

    "Precise rules are now provided for converting to and from
    unsigned integers. On a twos-complement machine, the operation is
    still virtual (no change of representation is required), but the
    rules are now stated inependent of representation."

        - Nathan

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to