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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6339fea48a1b8cda X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Enumeration representation clause surprise. Date: Sun, 15 Jun 2008 15:33:03 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <770ae1af-b9fd-4c8a-915c-a5cb3ea8fc81@c65g2000hsa.googlegroups.com> <87hcbybazk.fsf@willow.rfc1149.net> <4f5f512a-36e6-466e-a5a9-5f26857841f8@w4g2000prd.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1213558384 31309 192.74.137.71 (15 Jun 2008 19:33:04 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 15 Jun 2008 19:33:04 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:LSJZZLwbL/G5i0PJQkCj/c284VE= Xref: g2news1.google.com comp.lang.ada:716 X-Original-Bytes: 2636 Date: 2008-06-15T15:33:03-04:00 List-Id: Adam Beneschan writes: >...So > what number is stored in a 0-bit data item? Zero. An n-bit field is either signed or unsigned. When you load the field into a register, you take all the bits and add copies of the sign bit on the left (for signed) or zeros on the left (for unsigned). A 0-bit field must be unsigned (there's no sign bit!). So you take nothing, and add 32 zero bits on the left (on a 32-bit machine). Or you could think of it as an infinitely-long string of bits -- you sign extend or zero extend infinitely on the left to get the value. Then of course you can bias that 0 by anything -- range 100..100 can be stored in a zero-bit unsigned bitfield, biased by 100. (Or is that -100?) >...I suppose you could > arbitrarily decide it's zero (which would make some sense > mathematically) Yes, I think so. >... but it seems more commonsensical to say that nothing > is stored there because there ain't no bits to store anything in. But that view requires a special case. The natural unsigned range for n bits, where n >= 0, is 0..(2**n)-1. Which is 0..0 when n = 0. The natural signed (2's complement) range for n bits, where n > 0, is -(2**(n-1))..(2**(n-1))-1. Which makes no sense if n = 0, because we don't want to mess around with negative exponents (fractions) -- we're talking about integer ranges. - Bob