comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Bit Manipulations
Date: 1999/12/21
Date: 1999-12-21T00:00:00+00:00	[thread overview]
Message-ID: <385fbeb8_1@news1.prserv.net> (raw)
In-Reply-To: B9063F55105FD21189FE0000F8103B5B0216503E@emss35m04.owg.fs.lmco .com

In article 
<B9063F55105FD21189FE0000F8103B5B0216503E@emss35m04.owg.fs.lmco.com> ,
"Simon, Jb" <jb.simon@lmco.com> 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.




       reply	other threads:[~1999-12-21  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <B9063F55105FD21189FE0000F8103B5B0216503E@emss35m04.owg.fs.lmco .com>
1999-12-21  0:00 ` Matthew Heaney [this message]
1999-12-20  0:00 Bit Manipulations Simon, Jb
1999-12-21  0:00 ` Ted Dennison
1999-12-21  0:00 ` Mats Weber
1999-12-21  0:00 ` tmoran
1999-12-21  0:00   ` Matthew Heaney
1999-12-21  0:00 ` Robert I. Eachus
replies disabled

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