bit patterns of all ones

John Gilmore gnu at hoptoad.uucp
Fri Dec 19 20:20:44 AEST 1986


Ken Ballou seems to have presented good and valid reasons derived from H&S
that (unsigned)-1 must have all the bits on.  So far nobody has refuted
him.  I think he's right -- the cast to unsigned *must*, by the C language
definition, convert whatever bit pattern -1 has into all ones.  This
is no worse than casting -1 to float causing a change its bit pattern --
and it's for the same reason.

I think it's funny that Ben Mejia's message says that a word containing
all ones in ones complement machines is "an illegal representation" but
then goes on to tell us that such an illegal value is easily and portably
generated with ~0.  The value does not know how it was generated, Ben;
why is it illegal to get all ones with cast and a -, but legal to do it
with ~?  And what legislature is passing laws about bit patterns?  Invalid
values I can see, but are they going to arrest me for contraband bit patterns?
-- 
John Gilmore  {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu   jgilmore at lll-crg.arpa
Call +1 800 854 7179 or +1 714 540 9870 and order X3.159-198x (ANSI C) for $65.
Then spend two weeks reading it and weeping.  THEN send in formal comments! 



More information about the Comp.lang.c mailing list