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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no 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 06:50:04 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!isdnet!psinet-france!psiuk-f4!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Bitwise operators Date: Fri, 30 Mar 2001 09:39:44 -0500 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9a25ri$pnp$1@nh.pace.co.uk> References: <3AC474DE.85E8B1A4@earthlink.net> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 985963186 26361 136.170.200.133 (30 Mar 2001 14:39:46 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 30 Mar 2001 14:39:46 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: supernews.google.com comp.lang.ada:6246 Date: 2001-03-30T14:39:46+00:00 List-Id: 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" 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