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,705f377a5e04a446,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!feeder.erje.net!aioe.org!not-for-mail From: Dennis Hoppe Newsgroups: comp.lang.ada Subject: Bit operations in Ada Date: Fri, 23 May 2008 23:19:25 +0200 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: KTrJYjO2GHnKiaYtjR9UCw.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Thunderbird 3.0a1 (Macintosh/2008050714) Xref: g2news1.google.com comp.lang.ada:303 Date: 2008-05-23T23:19:25+02:00 List-Id: Hello, I'm new to Ada and bitwise operations is a new challenge in this realm. My objective is to manipulate some bit strings in Ada, especially: a) addition/subtraction mod 2**n, b) change bits directly (e.g, via array access) c) shift operations d) rotate operations e) and, xor, not, or I started with an array of booleans of size 2**n, that provides neat access to individual bits by means of an index. Unfortunately, addition/subtraction mod 2**n is not supported, but essential for me. Next, I tried modular types (mod 2**n), but ended up with not having direct access to individual bits. My last attempt was to use Interfaces.Unsinged_n. It is a solid package that simplifies the usage of bitwise operations for me by adding shift and rotate operations. Addition modulo n works well, but I have to dispense with direct bit access, too. So, what is coming next? Should I go with Interfaces.Unsinged_n and provide a suitable function that converts the used type into an array of boolean? Maybe, I'm ought to use directly an array of boolean and try to convert the array into an Unsigned_n; if required to add two bit-strings. I'm looking forward for some answers. Best regards, Dennis Best regards, Dennis