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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: How do you bitwise operations in Ada '83 and '95 Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <9315684D-C216-4EDA-8852-0A6BD4C275B0@amado-alves.info> Date: Thu, 20 Jul 2006 13:31:32 +0200 Message-ID: <1e7szqc5niq0u$.1oqd2mhiiccyx.dlg@40tude.net> NNTP-Posting-Date: 20 Jul 2006 13:31:32 MEST NNTP-Posting-Host: 25bb55cd.newsread2.arcor-online.net X-Trace: DXC=11o?Od0dQe6_78OXD477\?Q5U85hF6f;4jW\KbG]kaM8GSi?jHD8GO0H8kDP_db^=?[6LHn;2LCV>7enW;^6ZC`4IXm65S@:3>? X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:5833 Date: 2006-07-20T13:31:32+02:00 List-Id: 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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de