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,aac6281ad4fb7480 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Bit Manipulations Date: 1999/12/21 Message-ID: <385fbeb8_1@news1.prserv.net>#1/1 X-Deja-AN: 563468908 Content-transfer-encoding: 7bit References: Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 21 Dec 1999 17:54:00 GMT, 129.37.62.236 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-21T00:00:00+00:00 List-Id: In article , "Simon, Jb" wrote: > I recently was put onto a project which is written in Ada83. As it has been > some time since I last used Ada, I can't remember how to do basic Bit > Maipulations > (and can't find it in the books I have). > > For instance, I get a byte from a hardware port and want to mast off the > parity bit ( 16#07F#). > > I want to do... > > char_data := char_data AND 16#07F# Assuming your char_data has the type: type Bit_Array is array (Natural range <>) of Boolean; pragma Pack (Bit_Array); Char_Data : Bit_Array (0 .. 7); begin ... Char_Data := Char_Data and (0,0,0,0,0,1,1,1); That's the simplest way. As others have suggested, you can declare your own "and" operator, and then internally convert an integer literal to a bit array.