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,87fc78f2f4541d9 X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: bit manipulation Date: 1999/04/05 Message-ID: <7eak8l$r6u$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 462877308 References: <37072A45.2B3BCE90@home.com> X-Http-Proxy: 1.0 x9.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Mon Apr 05 15:18:53 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I) Date: 1999-04-05T00:00:00+00:00 List-Id: In article <37072A45.2B3BCE90@home.com>, jcchow@interchange.ubc.ca wrote: > Can anyone tell me how to do bit manipulation such as bitwise-and and > bitwise or? > > I am a C programmer. > > Thanks in advance. > > Jack Chow (Assuming you are using the most recent version of Ada) There are several ways of doing this. Which one is right for you depends on what you want to do with the object. If you also want to be able to manipulate the same objects as integers ( +, -, /, *, etc), then Ada's modular integer types were designed for this purpose. If all you ever want to look at individual bits and perform bitwise operations, then you can use a packed array of booleans indexed by an enumeration: type Status_Bit_Indices is (Success, Parity, ...); type Status_Bit_Array is array (Status_Bit_Indices) of Boolean; pragma Pack Status_Bit_Array; for Status_Bit_Array'size use 32; The boolean operations "and", "or", "not" etc. are predefined to work in a bitwise manner on such arrays. T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own