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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,afb6e61f9b1678d1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-03 20:07:53 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3F7E3982.2070801@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Bitwise XOR? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc02 1065236872 24.34.139.183 (Sat, 04 Oct 2003 03:07:52 GMT) NNTP-Posting-Date: Sat, 04 Oct 2003 03:07:52 GMT Organization: Comcast Online Date: Sat, 04 Oct 2003 03:07:52 GMT Xref: archiver1.google.com comp.lang.ada:194 Date: 2003-10-04T03:07:52+00:00 List-Id: Beard, Frank Randolph CIV wrote: > You don't even need the Unchecked_Conversion. > > The following should work: > > function "xor"(Left,Right : in Integer) return Integer is > pragma inline("xor"); > type Int_As_Mod is mod 2 ** Integer'size; > begin > return Integer( Int_As_Mod(Left) XOR Int_As_Mod(Right) ); > end "xor"; > > Theoretically, Unchecked_Conversion should be faster I guess. > Is that why you chose it, or did you do some timing tests > that showed a noticeable difference? First, the Unchecked_Conversion is correct. The above code will not do what you expect with negative numbers, it will raise an exception. The Unchecked_Conversion will not only prevent the "unnecessary" check, but will also be faster. -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig