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 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bill Findlay Newsgroups: comp.lang.ada Subject: Re: Creating several types from a base type and conversion Date: Sat, 18 Jan 2020 18:20:40 +0000 Organization: none Message-ID: <0001HW.23D383F80221AAB870000511B2EF@news.individual.net> References: <4b0649b3-aed2-44fd-822f-d6665b9352dd@googlegroups.com> <0001HW.23D35416021671CF70000511B2EF@news.individual.net> Reply-To: findlaybill@blueyonder.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net /t6ZqQa1LAkGoWiwecyyrgfn8BwlyRLKZj1XA2YNViIxtZzwwB X-Orig-Path: not-for-mail Cancel-Lock: sha1:qEJMhtT4kRzp1H+ZXlkj0KeVOBc= User-Agent: Hogwasher/5.24 Xref: reader01.eternal-september.org comp.lang.ada:57878 Date: 2020-01-18T18:20:40+00:00 List-Id: On 18 Jan 2020, Jeffrey R. Carter wrote (in article): > On 1/18/20 3:56 PM, Bill Findlay wrote: > > > > Use the type: > > > > mod 2**30 > > > > which provides all the bit handling you need. > > Except for shifts and rotations, which most instruction sets provide. > Shifts can be replaced by multiplication and division by powers of two. > Rotations are a little more complex. Or, using GNAT, e.g.: type word is mod 2**30; subtype word_shift_length is Natural range 0..30; function shift_word_left (W : word; amount : word_shift_length) return KDF9.word; function shift_word_right (W : word; amount : word_shift_length) return KDF9.word; function rotate_word_left (W : word; amount : word_shift_length) return KDF9.word; function rotate_word_right (W : word; amount : word_shift_length) return KDF9.word; All done. -- Bill Findlay