Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: semantics of arith comparisons Message-ID: <591@taumet.com> Date: 7 Feb 91 17:23:58 GMT References: <1991Feb6.085315.10468@sics.se> <589@taumet.com> Distribution: comp Organization: Taumetric Corporation, San Diego Lines: 21 I wrote: >Hex constants are of type unsigned int ... This is not correct, as Andy Koenig and Doug Gwyn pointed out. In ANSI C (3.1.3.2), the type of a hex constant (without L or U suffix) is the first in this list in which its value can be represented: int, unsigned int, long int, unsigned long int. In pre-ANSI C, a the type of a hex constant (without an L suffix) was int if it would fit in an unsigned int, and long otherwise. This led to some bizarre consequences: on a system with 16-bit ints, 0xFFFF had type int and the value -1, while 65535 had type long and value 65535. The ANSI rules give the more natural result that 0xFFFF has the value 65535 whether ints are 16 bits or longer. If ints are 16 bits, the type of 0xFFFF is unsigned int; if bits are longer, the type is int. -- Steve Clamage, TauMetric Corp, steve@taumet.com