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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.47.7 with SMTP id j7mr11692758ioo.31.1519755426407; Tue, 27 Feb 2018 10:17:06 -0800 (PST) X-Received: by 10.157.94.15 with SMTP id d15mr681318oti.4.1519755426223; Tue, 27 Feb 2018 10:17:06 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!o66no349568ita.0!news-out.google.com!a25ni545itj.0!nntp.google.com!w142no352396ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 27 Feb 2018 10:17:05 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.233.194; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.233.194 References: <001e93f1-b645-4312-8a29-caca3860b560@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <444f2814-d377-4c0b-8def-aee59034ee35@googlegroups.com> Subject: Re: 64-bit unsigned integer? From: "Dan'l Miller" Injection-Date: Tue, 27 Feb 2018 18:17:06 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2791 X-Received-Body-CRC: 1966574875 Xref: reader02.eternal-september.org comp.lang.ada:50690 Date: 2018-02-27T10:17:05-08:00 List-Id: Dan'l Miller wrote: > analogous to multiplying/dividing by powers of 2 being instead generated = as shift left/right instructions=20 J.P. Rosen wrote: > This is a common error: dividing by 2 is not the same as arithmetic=20 > shifting right (for negative numbers)!=20 Failing to read the manual is a common error too. x86 logical & arithmetic shifting instructions: http://jsimlo.sk/docs/cpu/= index.php/shl.html x86 roll-shifting instructions: http://jsimlo.sk/docs/cpu/index.php/ror.htm= l ARM barrel-shifter instructions: http://www.davespace.co.uk/arm/introducti= on-to-arm/barrel-shifter.html Please note that I wrote =E2=80=9Cinstructions=E2=80=9D (plural) there, as = in the whole family of shift instructions, both logical shift and arithmeti= c shift. (I said assembly/machine-code instructions there, not C's cripple= d shift operators.) Logical does not preserve 2s-complement representation= of negative numbers, but arithmetic does. In Intel x86 ISA, perhaps you e= ffectively chose SHR instead of SAR. In ARM ISA, perhaps you effectively c= hose LSR instead of ASR. If you are concerned about the rounding down towa= rd negative infinity instead of up toward zero for negative numbers, perhap= s ROR and the carry flag are more for you to fix up the rounding via the ca= rry flag as output (after using the CF to shift in the 0 or 1 to maintain t= he 2s-complement), which is RRX on ARM. All the while avoiding the more ex= pensive subtraction-comparison operations.