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=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f01d35116e753b6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.125.233 with SMTP id mt9mr16455553pbb.5.1332684107899; Sun, 25 Mar 2012 07:01:47 -0700 (PDT) Path: kz5ni32372pbc.0!nntp.google.com!news1.google.com!news.glorb.com!feeder.erje.net!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: xor Date: Sun, 25 Mar 2012 17:01:45 +0300 Organization: Tidorum Ltd Message-ID: <9t8mq9Fla4U1@mid.individual.net> References: Mime-Version: 1.0 X-Trace: individual.net qslbMg2WlBB079PGZNw64gzfskq4Cf+l67N0jWupuGXtBEgazf Cancel-Lock: sha1:sKVPPeBH9QTH234UOvOVW+ZOJDc= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-03-25T17:01:45+03:00 List-Id: On 12-03-25 17:28 , Michael Moeller wrote: > Hi, > > I'm wondering what this code in C looks like translated to Ada: > > unsigned char x, y, z; > ... > z = x ^ y; > ... > > Oddly enough, none of the manuals I have covers simple numerical > xor of two numbers stored in variables. Use a modular integer type to get the XOR operation: -- begin example procedure Show_Xor is type Unsigned_Byte_T is mod 256; x, y, z : Unsigned_Byte_T; begin x := 26; y := 33; z := x xor y; end Show_Xor; --end example If you also want shift and rotate operations, start from the types defined in the Interfaces package, such as Interfaces.Unsigned_8 and other sizes. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .