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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1eda8da8a6221ea7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-18 09:09:06 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!194.213.69.151!news.algonet.se!algonet!newsfeed1.uni2.dk!news.net.uni-c.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: bitwise operations in Ada95 Date: Wed, 18 Jul 2001 18:09:05 +0200 Organization: Centre for Chaos and Turbulence Studies, Niels Bohr Institute Message-ID: <3B55B4A1.56150A4B@nbi.dk> References: <9j2p76$6is$1@fang.dsto.defence.gov.au> <192e1f87.0107180742.4e2e83df@posting.google.com> NNTP-Posting-Host: alf.nbi.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.net.uni-c.dk 995472545 24302 130.225.212.55 (18 Jul 2001 16:09:05 GMT) X-Complaints-To: usenet@news.net.uni-c.dk NNTP-Posting-Date: Wed, 18 Jul 2001 16:09:05 +0000 (UTC) X-Mailer: Mozilla 4.77 [en] (X11; U; OSF1 V4.0 alpha) X-Accept-Language: fo,da,no,sv,is,de,fr,en Xref: archiver1.google.com comp.lang.ada:10167 Date: 2001-07-18T18:09:05+02:00 List-Id: Aquaman: > My question would be for a way to do bit shifting operations (vs. & |) > so for example shift left and shift right for use in mathmatical mult and div > opperations "*2" and "/2" works fine for me for that purpose (on modular types). Using packed arrays of booleans "(Bit_Pattern (Bit_Pattern'First + 1 .. Bit_Pattern'Last), 0)" and "(1, Bit_Pattern (Bit_Pattern'First .. Bit_Pattern'Last - 1))" could be used. But I would hide them in functions, and maybe allow shifting by more than one bit at a time. I am certain that all current Ada compilers will implement the first of these two solutions "the optimal way". I am not so certain about the second, but it could easily be checked. Anyway. The abstract concept you actually want to implement seems to be "*2" and "/2", so why not just use that. Jacob -- "The point is that I am now a perfectly safe penguin!"