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,5697899e4423465c X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: Boolean Representation Date: 1998/09/24 Message-ID: #1/1 X-Deja-AN: 394557559 Cache-Post-Path: wagasa.cts.com!kst@king.cts.com References: <6udkcj$87j$1@nnrp1.dejanews.com> <6uecer$3sf$1@nnrp1.dejanews.com> Organization: CTS Network Services Newsgroups: comp.lang.ada Date: 1998-09-24T00:00:00+00:00 List-Id: 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 <*> Qualcomm, San Diego, California, USA It takes a Viking to raze a village.