
Boost : 
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 20060527 17:05:27
Beman Dawes wrote:
>That isn't correct, AFAICT. An unsigned does support unary negation.
>
>5.3/9 says "The operand of the unary  operator shall have arithmetic or
>enumeration type and the result is the negation of its operand. Integral
>promotion is performed on integral or enumeration operands. The negative of
>an unsigned quantity is computed by subtracting its value from 2n, where n
>is the number of bits in the promoted operand. The type of the result is the
>type of the promoted operand."
>
>
The operator exists, but only for the language unsigned integers, which
aren't really unsigned integers, but modulo integers, as is obvious from
the definition of the negation. The same definition is impossible for a
(theoretically) infiniteprecision integer, because, lacking a number of
bits in the representation (n), there is no 2^n from which can be
subtracted.
Sebastian Redl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk