comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: bit manipulation
Date: 1999/04/05
Date: 1999-04-05T00:00:00+00:00	[thread overview]
Message-ID: <7eak8l$r6u$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 37072A45.2B3BCE90@home.com

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    




  parent reply	other threads:[~1999-04-05  0:00 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-04  0:00 bit manipulation Jack Chow
1999-04-04  0:00 ` Matthew Heaney
1999-04-05  0:00 ` dennison [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-11-07  0:00 Bit manipulation Sandro Binetti
2000-11-07  0:00 ` gdemont
2000-11-08  7:22   ` Sandro Binetti
2000-11-07  0:00 ` Larry Kilgallen
2000-11-07  0:00   ` John English
2000-11-08  0:00   ` gdemont
2000-11-08  0:00     ` Robert Dewar
2000-11-08  0:00       ` Sandro Binetti
2000-11-08  0:00         ` gdemont
2000-11-09  4:00           ` Ken Garlington
2000-11-09  0:00             ` Larry Kilgallen
2000-11-09  0:00               ` Ken Garlington
2000-11-08  0:00         ` Nicolas Brunot
2000-11-08  0:00         ` Dale Stanbrough
2000-11-09  0:00           ` Sandro Binetti
2000-11-09  0:00             ` Ken Garlington
2000-11-09  0:00             ` gdemont
2000-11-10  0:00             ` Scott Ingram
2000-11-09  3:59         ` Ken Garlington
2000-11-09  4:52         ` Robert Dewar
2000-11-08  0:00       ` gdemont
2000-11-08  0:00         ` Larry Kilgallen
2000-11-09  4:50           ` Robert Dewar
2000-11-10  0:00             ` Lao Xiao Hai
2000-11-09  4:47         ` Robert Dewar
2000-11-09  0:00           ` gdemont
2000-11-11  0:00       ` Redryder
2000-11-11  0:00         ` Jeff Carter
2000-11-11  0:00           ` Redryder
2000-11-12  2:07             ` Ken Garlington
2000-11-12  5:56             ` Jeff Carter
2000-11-12  0:00               ` Robert Dewar
2000-11-12  0:00                 ` tmoran
2000-11-13  0:00                   ` Robert Dewar
2000-11-14  0:00                     ` Marc A. Criley
2000-11-13  0:54                   ` Ken Garlington
2000-11-12  6:40               ` tmoran
2000-11-13  0:00         ` Lutz Donnerhacke
2000-11-13  0:00           ` Robert Dewar
2000-11-13  0:00             ` Lutz Donnerhacke
2000-11-13  0:00               ` Robert Dewar
2000-11-13  0:00                 ` Lutz Donnerhacke
2000-11-13  0:00           ` Robert Dewar
2000-11-13  0:00             ` Lutz Donnerhacke
2000-11-13  0:00               ` Robert Dewar
2000-11-13  0:00                 ` Lutz Donnerhacke
2000-11-13  0:00                   ` Pat Rogers
2000-11-13  0:00                     ` Brian Rogoff
2000-11-13  0:00                       ` F. Britt Snodgrass
2000-11-15  0:00                         ` Lutz Donnerhacke
2000-11-13  0:00                       ` Pat Rogers
2000-11-14  0:00                       ` Georg Bauhaus
2000-11-15  0:00                         ` Lutz Donnerhacke
2000-11-14  0:00                   ` Martin Dowie
2000-11-15  0:00                     ` Lutz Donnerhacke
2000-11-20  0:00                 ` Randy Brukardt
2000-11-21  0:00                   ` Lutz Donnerhacke
2000-11-21  0:00                     ` Stephen Leake
2000-11-22  0:00                       ` Lutz Donnerhacke
2000-11-08  7:18   ` Sandro Binetti
2005-02-07 12:37 Maurizio
2005-02-07 13:20 ` Martin Krischik
2005-02-07 15:32 ` Martin Dowie
2005-02-07 18:04   ` Martin Krischik
2005-02-08  0:32 ` Randy Brukardt
2005-02-08  3:11 ` Steve
2005-02-08 18:51   ` tmoran
replies disabled

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