Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: type of character constants Message-ID: <1989Mar18.221754.27335@utzoo.uucp> Organization: U of Toronto Zoology References: <13068@steinmetz.ge.com> <102@servio.UUCP> <10138@socslgw.csl.sony.JUNET> <1783@dlvax2.datlog.co.uk> <3711@xyzzy.UUCP> <1644@vicorp.UUCP> <766@twwells.uucp> <1813@dlvax2.datlog.co.uk> Date: Sat, 18 Mar 89 22:17:54 GMT In article <1813@dlvax2.datlog.co.uk> scm@datlog.co.uk ( Steve Mawer ) writes: >So what is the 'correct' value for '\377', 255 or -1? Precisely! :-) The correct value is "255 or -1". If char is signed in the particular implementation, the value is -1 (assuming 8-bit chars); if char is unsigned, the value is 255. The X3J11 rule is essentially that 'x' == (int)(char)'x' for all x, so it depends on whether conversion of char to int sign-extends. Code that depends on one particular choice is non-portable. -- Welcome to Mars! Your | Henry Spencer at U of Toronto Zoology passport and visa, comrade? | uunet!attcan!utzoo!henry henry@zoo.toronto.edu