Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: IsUnsigned() function (retiring injured) Message-ID: <25836@mimsy.umd.edu> Date: 2 Aug 90 05:46:49 GMT References: <1990Jul27.161339.14712@kfw.COM> <8118@ncar.ucar.edu> <621@.tetrauk.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 20 In article <621@.tetrauk.UUCP> rick@.tetrauk.UUCP (Rick Jones) writes: >Perhaps I finally understand the ANSII promotion rules at last! Probably not. :-) (Incidentally, `ANSI' has only one `I'; it is `ASCII' that has two.) Actually, the rule is fairly easy to state: `In ANSI C, when an unsigned type is promoted% to some other type, it becomes signed (without changing value) if and only if the new type is actually bigger.' In practise, this means that you have to know whether sizeof(short) < sizeof(int) and whether sizeof(char) < sizeof(int). Alternatively, never let values promote without using a cast to a non-promoting type; this avoids the problem entirely. ----- % `Promotion' is not the same as `conversion' or `assignment'. See the standard (X3.159-1989) for an exact description. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris