From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,FROM_WORDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6e6cdf6ff50e684 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-10 08:37:20 PST Path: supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed.yosemite.net!news-out.cwix.com!newsfeed.cwix.com!howland.erols.net!nntp.flash.net!news.flash.net!not-for-mail From: "Ken Garlington" Newsgroups: comp.lang.ada References: <95tqbh$ag7$1@nnrp1.deja.com> <962mh2$f9v$1@nnrp1.deja.com> Subject: Re: Representation clause for enumeratives X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: <27eh6.3786$y03.254014@news.flash.net> Date: Sat, 10 Feb 2001 16:37:18 GMT NNTP-Posting-Host: 65.65.209.243 X-Complaints-To: abuse@flash.net X-Trace: news.flash.net 981823038 65.65.209.243 (Sat, 10 Feb 2001 10:37:18 CST) NNTP-Posting-Date: Sat, 10 Feb 2001 10:37:18 CST Organization: FlashNet Communications, http://www.flash.net Xref: supernews.google.com comp.lang.ada:5100 Date: 2001-02-10T16:37:18+00:00 List-Id: "Robert Dewar" wrote in message news:962mh2$f9v$1@nnrp1.deja.com... : In article , : "Ken Garlington" wrote: : > I don't know if either behavior is considered "wrong" by the : standard. I'm : > not comfortable with the GNAT behavior, since it treats : 16#8000_0000# as a : > legal 32-bit integer value, although it is not in the range : Standard.Integer : > on the same machine. : : Who says that the range of enumeration values is restricted : to Standard.Integer, in fact no one says it... Well, actually GNAT says it under certain circumstances... see subsequent posts! This is the part I'm not confortable with... that the allowable range for a enumeration type which is explicitly constrained to 32 bits shifts depending upon how the enumeration values are written. Again, I see its utility in practice, but I can also see how it might confuse new Ada users who try to do the same thing in different contexts (see end). , and the RH in : the RM encourages you to go up to maxint which for GNAT : is 2**63-1. Why you should be uncomfortable because GNAT : does NOT implement a limitation which : : (a) would not be helpful : (b) would violate implementation advice : : is puzzling indeed! : : > This just encourages the confusion between hex numbers : > and bit-patterns. I do see the utility of doing it this way, : > however. : : I don't understand the confusion. GNAT chooses a large enough : signed or unsigned integer type to cover the range of values : provided. : : Note that 16#8000_0000# is the number 2**32, it is a POSITIVE : number, nothing at all to do with the largest negative number. : I think the confusion is coming from the use of base 16, and : suddenly that is translating into bit patterns in your mind??? : : Any time you write 16#8000_0000# in your program, you could : equally well write 2147483648. The meaning is 100% identical. : If the first looks like a bit pattern to you, and the second : looks like an integer, then that's your confusion, not Ada's : :-) Actually, the confusion is from the original poster (we really have to work on your social skills, Robert :). The confusion is that 16#8000_0000# does, indeed, look very much like a bit pattern as represented in certain other popular languages. Further adding to the confusion is that this enumeration value, when read as an Integer, is in fact not 2147483648 but -2147483648. Particularly for engineers with a hardware/assembly background (who also tend to be the ones who want to write this kind of code), the distinction between an Unsigned_Integer, an Integer, and an integer on a two's-complement machine is often difficult to grasp. Trust me -- I get to hear about this confusion all of the time. In fact, on one recent project, I had to write and distribute a three-page paper on this sort of distinction due to the number of questions in this area (e.g. "Why won't this stupid compiler do bit strings right?"). : : : Sent via Deja.com : http://www.deja.com/