Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.std.c Subject: Re: integer value of multi-char constants Message-ID: <20205@mimsy.umd.edu> Date: 17 Oct 89 06:25:48 GMT References: <29588@gumby.mips.COM> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 19 In article <29588@gumby.mips.COM> lai@mips.COM (David Lai) writes: >on a mips, vax, and sun the following is true: > '\001\377' == '\000\377'; >however on the same machines: > '\001\177' != '\000\177'; >The question is: does the above behaviour conform to ANSI C? Certainly. The more important question is `why would anyone expect otherwise?' (Remember that character constants are constant expressions with type int---NOT type char!) The machines listed above all form two-character constants by computing (more or less) c0*256+c1 (or c1*256+c0), where c0 and c1 are the first and second characters in the constant. Hence '\001\177' is 0x17f and '\000\177' is 0x07f. It would be very strange for these to be equal. -- `They were supposed to be green.' In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris