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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f7a6385d57e1fb5b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-30 05:01:56 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!newsfeed.berkeley.edu!ucberkeley!blanket.mitre.org!news.tufts.edu!logbridge.uoregon.edu!netnews.com!feed2.onemain.com!feed1.onemain.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3AC474DE.85E8B1A4@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Bitwise operators References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 30 Mar 2001 12:56:05 GMT NNTP-Posting-Host: 63.178.180.30 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 985956965 63.178.180.30 (Fri, 30 Mar 2001 04:56:05 PST) NNTP-Posting-Date: Fri, 30 Mar 2001 04:56:05 PST Xref: supernews.google.com comp.lang.ada:6241 Date: 2001-03-30T12:56:05+00:00 List-Id: 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