comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: Bitwise operators
Date: Fri, 30 Mar 2001 09:39:44 -0500
Date: 2001-03-30T14:39:46+00:00	[thread overview]
Message-ID: <9a25ri$pnp$1@nh.pace.co.uk> (raw)
In-Reply-To: 3AC474DE.85E8B1A4@earthlink.net

IIRC, you also get logical operations on arrays of Boolean - this can be
very useful as well - especially if the array is packed into a convenient
machine word size. (See ARM 4.5.1(2..6), etc.) It is handy when you want to
set specific bits in the word as well as performing logical operations
between words. Of course, the relative efficiency of this is going to be
compiler dependent. Some may properly degenerate it to single machine
instructions whereas others may go around the block a few times. YMMV.

MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas    www.pacemicro.com
Enabling the digital revolution
e-Mail:    marin.condic@pacemicro.com
Web:      http://www.mcondic.com/



"Marc A. Criley" <mcqada@earthlink.net> wrote in message
news:3AC474DE.85E8B1A4@earthlink.net...
> Bob Gratton wrote:
> >
> > Are there any bitwise operators in ADA? I'd like to compare two binary
> > numbers with AND and OR... Is it possible?
> >
> > Thanx!
>
> Most definitely!
>
> One of the primary uses of modular types is in support of logical
> operations.  Here's a little program that illustrates their use:
>
> with Text_IO; use Text_IO;
>
> procedure Mod_Demo is
>
>    type A_Modular_Type is mod 2**16;
>
>    A : A_Modular_Type := 511;
>    B : A_Modular_Type := 255 * 256;
>
> begin
>    Put_Line("A and B =" & A_Modular_Type'Image(A and B));
>    Put_Line("A or  B =" & A_Modular_Type'Image(A or  B));
>    Put_Line("A xor B =" & A_Modular_Type'Image(A xor B));
> end Mod_Demo;
>
> For more info on modular types, see section 3.5.4 of the Ada Reference
> Manual (which covers all the "integer" types), and 4.5.1 for info on how
> modular types are operated on by the logical operators.
>
> Marc A. Criley
> Senior Staff Engineer
> Quadrus Corporation
> www.quadruscorp.com





      reply	other threads:[~2001-03-30 14:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-29 18:54 Bitwise operators Bob Gratton
2001-03-29 19:03 ` chris.danx
2001-03-30 14:50   ` Ted Dennison
2001-03-30 21:05     ` Robert A Duff
2001-04-02 13:27       ` Ted Dennison
2001-04-02 14:44         ` Robert A Duff
2001-04-02 16:05           ` Ted Dennison
2001-03-30  6:54 ` Martin Dowie
2001-03-30 12:56 ` Marc A. Criley
2001-03-30 14:39   ` Marin David Condic [this message]
replies disabled

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