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,9dec3ff1604723d9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!newsr1.ipcore.viaginterkom.de!news-peer1!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: "Martin Dowie" Newsgroups: comp.lang.ada Subject: Re: Bitmanipulation in Ada Date: Wed, 18 Aug 2004 21:53:44 +0000 (UTC) Organization: BT Openworld Message-ID: References: NNTP-Posting-Host: host81-154-190-170.range81-154.btcentralplus.com X-Trace: sparta.btinternet.com 1092866024 11605 81.154.190.170 (18 Aug 2004 21:53:44 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Wed, 18 Aug 2004 21:53:44 +0000 (UTC) X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MSMail-Priority: Normal X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:2819 Date: 2004-08-18T21:53:44+00:00 List-Id: Bernd Specht wrote: > 2. I did not found shift and rotate operations. Did I miss something > or are there really none? Check out package "Interfaces" they are all there - as are some common predefined types. > 3. When I want treat a value both as an integer and as a boolean > array, how can i do this? In pascal I would use a tagless record like Assuming you had a _really_ good reason to need to think of the data in both terms, you have a number of options: 1) Unchecked_Conversion; procedure Foo (Y : Unsigned_8) is procedure To_Array_8 is new Ada.Unchecked_Conversion (Unsigned_8, Array_8); X : Array_8 := To_Array_8 (Y); begin ... 2) Address clause to 'overlay' 2 variables at the same address; procedure Foo (Y : Unsigned_8) is X : Array_8; for X'Address use Y'Address; begin ... 3) Variant record with a representation clause; type Variant (Is_Array : Boolean := False) is record case Is_Array is when False => U : Unsigned_8; when True => A : Array_8; end case; end record; for Variant use record U at 0 range 0 .. 7; A at 0 range 0 .. 7; end record; This will leave it to the compiler where to put "Is_Array" There are pros and cons to each - I'd rather use Ada.Unchecked_Conversion to make it explicit that I'm switching representations. Cheers -- Martin