comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@king.cts.com>
Subject: Re: Boolean Representation
Date: 1998/09/25
Date: 1998-09-25T00:00:00+00:00	[thread overview]
Message-ID: <yecemt0kp9f.fsf@king.cts.com> (raw)
In-Reply-To: 6ug5l7$tsb$1@nnrp1.dejanews.com

dennison@telepath.com writes:
> In article <yecogs5gidf.fsf@king.cts.com>,
>   Keith Thompson <kst@king.cts.com> wrote:
[...]
> >
> > I don't believe even that much is guaranteed.  A compiler I worked on
> > used, for some targets, the representation (False => 0, True => -1)
> > (i.e., a literal True value was represented with all bits set to 1
> > (2's-complement) rather than just the last bit set to 1).  This made
> > tests and logical operations more efficient, at the expense of some
> > extra code for Boolean'Pos, Boolean'Val, "<", ">", etc.
> 
> I suspect their claim would be: (False => 0, True => 2**32 - 1).
> --
> T.E.D.

No, no such claim is necessary.  Also, this was an Ada-83 compiler
with no unsigned types (and no integer types larger than 32 bits), so
2**32-1 wasn't even a legal value.  False was represented as 0, True
was represented as -1, and the compiler generated extra code where
necessary to ensure that all the language-defined operations
(Boolean'Pos, "<", ">=", Boolean'Image, etc.) worked as specified.
The language forbids a user from specifying a non-increasing
representation for an enumeration type, but it doesn't forbid an
implementation from doing so for type Boolean.

Here's another interesting question.  Suppose some perverse
implementation used an internal representation of (False => 1, True => 0)
for type Boolean, and generated extra code to make all the predefined
operations work properly.  A packed array of 32 Booleans, for example,
would occupy 32 bits, but setting it to (others => True) would clear
all 32 bits.  I'm not suggesting that this would ever be a good idea,
but would it actually violate the RM?

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst> <*>
Qualcomm, San Diego, California, USA  <http://www.qualcomm.com>
It takes a Viking to raze a village.




  reply	other threads:[~1998-09-25  0:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-24  0:00 Boolean Representation matthew_snyder
1998-09-24  0:00 ` dennison
1998-09-24  0:00   ` Keith Thompson
1998-09-25  0:00     ` dennison
1998-09-25  0:00       ` Keith Thompson [this message]
1998-09-26  0:00         ` Tucker Taft
1998-09-26  0:00           ` Keith Thompson
1998-09-27  0:00             ` null pointer representation (was: Boolean Representation) Arthur Evans Jr
1998-09-27  0:00               ` Keith Thompson
1998-09-28  0:00               ` dewarr
1998-09-28  0:00                 ` Lieven Marchand
1998-09-28  0:00                 ` Keith Thompson
1998-09-28  0:00                   ` dewarr
1998-09-30  0:00                     ` Keith Thompson
1998-10-02  0:00                       ` Robert I. Eachus
1998-09-27  0:00             ` Boolean Representation dewarr
1998-09-27  0:00           ` dewarr
1998-09-24  0:00 ` dewarr
1998-09-24  0:00   ` Samuel T. Harris
1998-09-25  0:00     ` dewarr
1998-09-27  0:00       ` Samuel T. Harris
1998-09-28  0:00         ` dewar
1998-09-24  0:00   ` matthew_snyder
1998-09-24  0:00     ` dennison
1998-09-24  0:00     ` Tom Moran
1998-09-25  0:00       ` dewarr
1998-09-25  0:00         ` Tom Moran
1998-09-25  0:00     ` Robert I. Eachus
1998-09-25  0:00     ` dewarr
  -- strict thread matches above, loose matches on Subject: below --
1998-09-24  0:00 matthew_snyder
1998-09-25  0:00 ` Tucker Taft
1998-09-25  0:00   ` dewarr
1998-09-25  0:00   ` dewarr
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox