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-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.74.201 with SMTP id w9mr16504986pbv.0.1332685125697; Sun, 25 Mar 2012 07:18:45 -0700 (PDT) Path: kz5ni32413pbc.0!nntp.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Michael Moeller Newsgroups: comp.lang.ada Subject: Re: xor Date: Sun, 25 Mar 2012 16:16:00 +0100 Message-ID: References: <9t8mq9Fla4U1@mid.individual.net> Mime-Version: 1.0 X-Trace: individual.net se/cUIlMUly9pQzPy9qGJwQvHj2zyaFY+hXI4LAGa5AYHUW49x X-Orig-Path: kodiak1!mic2 Cancel-Lock: sha1:nDlJuUWG6WNpdmIH6jRBn1Ff8iQ= X-X-Sender: mic2@kodiak1 In-Reply-To: <9t8mq9Fla4U1@mid.individual.net> X-Received-Bytes: 1790 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Date: 2012-03-25T16:16:00+01:00 List-Id: Thank you for your quick answer. Can I use Unsigned_Byte_T to read in a byte from a file as in C? I haven't looked into this yet. Regards, Michael On Sun, 25 Mar 2012, Niklas Holsti wrote: > 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 > . @ . >