Article View: comp.std.c
Article #5732Re: Sizes, alignments, and maxima
From: Doug Gwyn
Date: Thu, 23 Feb 1989 05:41
Date: Thu, 23 Feb 1989 05:41
22 lines
1960 bytes
1960 bytes
In article <11838@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >Question for comp.std.c (to which I've redirected followups): I've been told >that the Cray-2 has sizeof(int) == 8, yet INT_MAX == 0x7FFFFFFF (i.e. the >arithmetic is only accurate to 4 bytes when using int). Is this legal in a >conforming implementation? I think I can prove that UINT_MAX must be 2*^64-1, >but I'm less sure about INT_MAX. Section 3.1.2.5 has a restriction to binary >architectures, which by the definition in the footnote seems to require every >bit except the highest to represent a power of two; should this be interpreted >as a requirement that 2*^63-1 must be representable in an 8-byte int? I think an implementation such as you describe is legal. What is required is that integers be represented in a binary numeration system, that a nonnegative signed integer of a given size have the same representation as the corresponding unsigned integer with the same value, that all integers in the ranges given by INT_MAX etc. be representable, and that unsigned arithmetic be performed modulo UINT_MAX+1 (similarly for unsigned long, etc.). I don't see any way these requirements can be combined to "prove" that every bit pattern contained in the "sizeof" soace has to be interpretable as a valid integral value. In fact I'm pretty sure we didn't want to require that, since (as you note) some architectures really don't support it.
Technical Details
Message-ID:
<9692@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!ncifcrf!nlm-mcs!adm!smoke!gwynReferences:
<2508@ssc-vax.UUCP> <8943@alice.UUCP> <830@atanasoff.cs.iastate.edu> <11838@haddock.ima.isc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!haven!ncifcrf!nlm-mcs!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.std.c Subject: Re: Sizes, alignments, and maxima Message-ID: <9692@smoke.BRL.MIL> Date: 23 Feb 89 05:41:12 GMT References: <2508@ssc-vax.UUCP> <8943@alice.UUCP> <830@atanasoff.cs.iastate.edu> <11838@haddock.ima.isc.com> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 22