Lew Pitcher wrote:
>
> On Thu, 11 Sep 2003 19:08:19 +0100, "Malcolm" <(EMail Removed)>
> wrote:
>
> >
> >"Mantorok Redgormor" <(EMail Removed)> wrote in message
> >> What does a trap representation mean in the standard?
> >> And how can ~0 cause a trap representation? Could someone point
> >> out the relevant sections in the standard?
> >>
> >A trap representaion is an illegal value for a variable to hold.
> [snip]
> >All bits set is allowed as a trap value. Thus ~0 could potentially trap.
>
> More specifically, on a onescomplement machine, all bits set is a potential
> trap representation, as it represents the value you get when you evaluate
> negative zero {(0)}.
>
> On a two's complement machine, 0 == all bits zero == 0
> On a one's complement machine, 0 == all bits one != 0
> On either machine ~0 == all bits one != 0
>
> But the C abstract machine doesn't recognize a difference between 0 and 0, thus
> making the one's complement expression a potential trap value ("cant happen").
>
> 
> Lew Pitcher
> IT Consultant, Enterprise Technology Solutions
> Toronto Dominion Bank Financial Group
>
> (Opinions expressed are my own, not my employers')
For integer types (signed or unsigned, short or long), would all ones be
an illegal value? I can see it for floats/doubles, but for integers???
On every platform I have encoutered with 16bit shorts and 32bit ints,
USHRT_MAX is 65535, which is sixteen ones in binary, and MAX_INT (or
MAX_INT) is 4294967295 which is 32 ones. For these cases, "all ones"
must be a legal value.

Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R94 (206)5445225
