From: "Marc A. Criley" <mcqada@earthlink.net>
Subject: Re: Bitwise operators
Date: Fri, 30 Mar 2001 12:56:05 GMT
Date: 2001-03-30T12:56:05+00:00 [thread overview]
Message-ID: <3AC474DE.85E8B1A4@earthlink.net> (raw)
In-Reply-To: qxLw6.488391$Pm2.7613079@news20.bellglobal.com
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
next prev parent reply other threads:[~2001-03-30 12:56 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 [this message]
2001-03-30 14:39 ` Marin David Condic
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox