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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ffdd4d59cbfb4caf X-Google-Attributes: gid103376,public From: jeffrey.m.creem@lmco.com (Jeff Creem) Subject: Re: Ada 95 Numerics questions for the experts Date: 1997/08/27 Message-ID: #1/1 X-Deja-AN: 268652583 Distribution: world References: <3401C14B.480@gsfc.nasa.gov> <01bcb2f2$b512f700$928871a5@dhoos> Organization: Jeff Creem Newsgroups: comp.lang.ada Date: 1997-08-27T00:00:00+00:00 List-Id: In article <01bcb2f2$b512f700$928871a5@dhoos>, "David C. Hoos, Sr." wrote: >Just a couple of points, viz.: > > 1. The DEC Ada compiler for VAXen allowed biased rep clauses, as well. > It's gratifying that gnat chose to implement this also. > > 2. The problem with your packed array example, however, is that what you > are asking the compiler to do is to force array elements which are >smaller than > one byte to straddle byte boundaries. No compiler likes to do this, >as far as I > know. (Record components straddling byte boundaries, are another >matter, and they But VADS, Apex and GNAT all do handle this (essentially) > are handled quite nicely without any ugly source code). > Simply using pragma Pack instead of a "for 'size use 24" clause will >result in your > 8-element x 3-bit array occupying 32 bits, which is not bad at all. > Undoubtedly, the extra code required to mask and shift the varying >amounts as Nope. The AdaMajic front end (Green hills in this case) rounds the components to 8 bits even in the precense of a pragma pack you get a 64 Byte array. > a function of the array index would substantially exceed the one >byte of array > size saved. Besides, even if the compiler did give you your 24-bit >array, it would > probably skip to the next 32-bit boundary for the next object in >memory, anyway. Actually in the real code that the example came from, the array was an element of a record with another field. The total length of the record was then 32 bits. > Even gnat will not give you a 24-bit array for this case (at least >the WinNT version 3.09). > It gives you a 32 bit array (which Is what I would expect) but does allow you to stick it in a record with another 8 bits and have a structure which is a total of 32 bits long.. Again very nice