Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Is something wrong with the compiler ? Message-ID: <1990Sep27.165348.1589@zoo.toronto.edu> Organization: U of Toronto Zoology References: <884@gtenmc.UUCP> <143014@sun.Eng.Sun.COM> Date: Thu, 27 Sep 90 16:53:48 GMT In article <143014@sun.Eng.Sun.COM> eager@ringworld.Eng.Sun.COM (Michael J. Eager) writes: >> printf(" Maxint : %d\na = %d\n", ( int )(( unsigned ) ~0 >> 1 ) , >The assignment of a = ~0 will make a = -1. When this is shifted >right by one bit, and the sign bit is set to zero, a becomes >MAXINT, which you then converted to unsigned and then int... Careful... Casts bind tighter than binary operators; the unsigned conversion is being done *before* the shift. -- TCP/IP: handling tomorrow's loads today| Henry Spencer at U of Toronto Zoology OSI: handling yesterday's loads someday| henry@zoo.toronto.edu utzoo!henry