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 Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!xara.net!gxn.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How do you bitwise operations in Ada '83 and '95 Date: Sat, 22 Jul 2006 09:57:01 +0100 Organization: Pushface Message-ID: References: <9315684D-C216-4EDA-8852-0A6BD4C275B0@amado-alves.info> <1e7szqc5niq0u$.1oqd2mhiiccyx.dlg@40tude.net> <71nkuwdmd7v5.xs4ho9ifpcfx$.dlg@40tude.net> <130aai4of5k0s.1175ed13axp2v.dlg@40tude.net> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1153558622 1739 62.49.19.209 (22 Jul 2006 08:57:02 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sat, 22 Jul 2006 08:57:02 +0000 (UTC) Cancel-Lock: sha1:QGjvqT1RqBtyZgVXt3caAKqbsxM= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news2.google.com comp.lang.ada:5874 Date: 2006-07-22T09:57:01+01:00 List-Id: "Dmitry A. Kazakov" writes: > I can't tell for C. Does ANSI C standard require (x<<1) == (x*2)? >From the Committee Draft WG14/N1124 of May 6 2005, p83, with minimal editing, 4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1�2^E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1�2^E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined. 5 The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 / 2^E2. If E1 has a signed type and a negative value, the resulting value is implementation-defined.