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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd398ca223dbbfd6,start X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: 'Size (novice question) Date: 2000/02/18 Message-ID: <38ACC0CD.B03EB020@earthlink.net>#1/1 X-Deja-AN: 587199204 Content-Transfer-Encoding: 7bit References: <38ACA68D.CEA7E03F@interact.net.au> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 950849343 63.10.51.149 (Thu, 17 Feb 2000 20:49:03 PST) Organization: EarthLink Network, Inc. MIME-Version: 1.0 Reply-To: jrcarter@acm.org NNTP-Posting-Date: Thu, 17 Feb 2000 20:49:03 PST Newsgroups: comp.lang.ada Date: 2000-02-18T00:00:00+00:00 List-Id: G wrote: > Type Byte is mod 2**8; > for Byte'Size use 8; > > why is the 'Size postfix used to set the size to > 8 bits when I would have thought that mod 2**8 > did the same thing. In most cases you would probably be right. BUT ... It is perfectly OK for the compiler to use more bits than necessary. Perhaps the architecture is such that loading a 32-bit word into a register is faster than loading an 8-bit byte. The type definition only defines the number of values that objects of the type can have (256, in this case. A 'Size definition instructs the compiler to use a specific number of bits. Note that this works both ways: type Half_Word is mod 2 ** 8; for Half_Word'Size use 16; Here we want to use one byte out of a (16-bit) word. The range of values can be stored in 8 bits, but we are requiring that objects of this type occupy 16 bits. -- Jeff Carter "You tiny-brained wipers of other people's bottoms!" Monty Python & the Holy Grail