🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1950

Range of Enum Constants

#1950
From: Andreas Kaiser
Date: Mon, 05 Nov 1990 15:59
38 lines
1698 bytes
In your msg to All, dated <05 Nov 90 08:31>, it said:

 KB> enum { A = (int)0x8001, };
 KB>         but rejects this:
 KB> enum { B = (int)0x8000, };

 KB> enum.c(16) : error C2141: value out of range for enum constant

 KB>         This doesn't make any sense, since both are valid values for a
 KB>  16-bit integer.

0x8000 is NOT a valid integer. -0x8000 IS a valid integer.

 KB>         This may be related to something I noticed in <limits.h>:

 KB> #define SHRT_MIN      (-32767)
 KB> #define SHRT_MAX       32767

 KB>         This is clearly wrong.  I don't have a copy of the ANSI
 KB> standard, but I suppose it is possible that it requires that the the
 KB> _MIN and _MAX constants for a signed integral type have the same
 KB> absolute value.

BTW: Did you mean (-32768) ? The numbers in your include-file extract above HAVE the same absolute value.

I have not seen the mentioned restriction to symetrical limits in the MWC ANSI C book. It would enforce a one-s complement representation for integers. A funny idea today. 

                Andreas

 A funny idea today. 

                Andreas

--  
:::::::::::::::::::: uucp: kaiser@ananke.stgt.sub.org
:: Andreas Kaiser :: fido: 2:509/5.2512 & 2:507/18.7206
::::::::::::::::::::
Technical Details
Message-ID: <2.27359B4D@ananke.stgt.sub.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!smurf!nadia!ananke!kaiser

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!smurf!nadia!ananke!kaiser
From: kaiser@ananke.stgt.sub.org (Andreas Kaiser)
Newsgroups: comp.std.c
Subject: Range of Enum Constants
Message-ID: <2.27359B4D@ananke.stgt.sub.org>
Date: 5 Nov 90 15:59:01 GMT
Organization: Ananke, Stuttgart, FRG
Lines: 38