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-Thread: 103376,553a6b79b2471571 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!atl-c08.usenetserver.com!news.usenetserver.com!pc03.usenetserver.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: How do you bitwise operations in Ada '83 and '95 References: <9315684D-C216-4EDA-8852-0A6BD4C275B0@amado-alves.info> <1e7szqc5niq0u$.1oqd2mhiiccyx.dlg@40tude.net> From: Stephen Leake Date: Fri, 21 Jul 2006 05:58:18 -0400 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt) Cancel-Lock: sha1:YtjJpTp1+S0xSAlil2z9drEz6oM= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 0056244c0a53ce73ae4a403865 Xref: g2news2.google.com comp.lang.ada:5857 Date: 2006-07-21T05:58:18-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Thu, 20 Jul 2006 05:03:23 -0400, Stephen Leake wrote: > >> Marius Amado-Alves writes: >> >>> Note that I don't do bit shifting. Instead I multiply or divide by a >>> magnitude. I don't think bit shifting is portable. >> >> See LRM B.2, Interfaces.Shift_Left, Shift_Right, Rotate_Left, Rotate_Right. > > Hmm, it reads (Ada 95): > > "{shift} {rotate} For each such modular type in Interfaces, shifting and > rotating subprograms as specified in the declaration of Interfaces above. > These subprograms are Intrinsic. They operate on a bit-by-bit basis, using > the binary representation of the value of the operands to yield a binary > representation for the result." > > That looks non-portable to me. > > Here is my definition of "portable": > > Let T is a modular type Unsigned_n compiled on two different machines. For > any valid X of T the result of Shift_Left (X, m) yields same numerical > value on both machines. > > I don't know if that was overlooked or that was an intent of language > designers to get at the underlying machine representation. Probably the > latter. I'm not a language lawyer, though. I'm missing something here. Assuming machines A and B both have Unsigned_16, please show me an Ada statement that produces different results on the two machines. I can see shift/rotate is non-portable if machine B doesn't have Unsigned_16, but otherwise I don't see the problem. Hmm. I suppose if machine A is one's complement, and machine B is two's compliment? No, the Unsigned bit representation is still the same; that's why these operations are not defined on signed types. -- -- Stephe