From: Keith Thompson <kst@king.cts.com>
Subject: Re: Boolean Representation
Date: 1998/09/24
Date: 1998-09-24T00:00:00+00:00 [thread overview]
Message-ID: <yecogs5gidf.fsf@king.cts.com> (raw)
In-Reply-To: 6uecer$3sf$1@nnrp1.dejanews.com
dennison@telepath.com writes:
> In article <6udkcj$87j$1@nnrp1.dejanews.com>,
[...]
> I believe the only guarantee you get is that the value of True is larger than
> the value of False.
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.
It's true that a user-defined enumeration representation clause cannot
legally specify such a representation, but there's nothing preventing
the compiler from doing so.
Of course, for a 1-bit Boolean (a member of a packed array or record),
this is equivalent to (False => 0, True => 1).
I think the original question had to do with 1-bit Booleans. I
suppose it's conceivable that some implementation might represent
False as 1 and True as 0 in this context, but it would be perverse.
If you really care about how the bits are set, it's probably safer to
use modular types.
> To get the behavior you want portably, do a:
>
> Boolean'pos(Boolean_Variable)
Agreed.
--
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.
next prev parent reply other threads:[~1998-09-24 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 [this message]
1998-09-25 0:00 ` dennison
1998-09-25 0:00 ` Keith Thompson
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 ` 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-28 0:00 ` Lieven Marchand
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 ` matthew_snyder
1998-09-24 0:00 ` Tom Moran
1998-09-25 0:00 ` dewarr
1998-09-25 0:00 ` Tom Moran
1998-09-24 0:00 ` dennison
1998-09-25 0:00 ` Robert I. Eachus
1998-09-25 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
-- 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