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!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.uni-stuttgart.de!carbon.eu.sun.com!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: "Martin Dowie" Newsgroups: comp.lang.ada Subject: Re: Bitmanipulation in Ada Date: Thu, 19 Aug 2004 20:29:30 +0000 (UTC) Organization: BT Openworld Message-ID: References: <87k6vwrwym.fsf@insalien.org> NNTP-Posting-Host: host81-154-184-237.range81-154.btcentralplus.com X-Trace: titan.btinternet.com 1092947370 27518 81.154.184.237 (19 Aug 2004 20:29:30 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Thu, 19 Aug 2004 20:29:30 +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:2875 Date: 2004-08-19T20:29:30+00:00 List-Id: Bernd Specht wrote: > Sorry, I and b are as mentioned earlier: > >>> TYPE ov is record >>> case boolean of >>> true : i : integer; >>> false : byte_array; >>> end; >>> end; Well, this isn't a complete solution (I've got a 4-year old to put to bed right now...) but it could send you on an alternative course (if the algorithm you posted is doing what I think it is! ;-) procedure Alternative (I : Unsigned_32) is K1, K2 : Unsigned_32; begin K1 := 16#8000_0000#; K2 := 16#0000_0001#; loop declare K1_Mask_Off : Unsigned_32 := 16#FFFF_FFFF# xor K1; K1_Mask_On : Unsigned_32 := 16#FFFF_FFFF# and K1; X1, X2 : Unsigned_32; begin Put ("K1"); IO.Put (K1, Base => 16); New_Line; Put ("K2"); IO.Put (K2, Base => 16); New_Line; Put ("K1_Mask_Off = "); IO.Put (K1_Mask_Off, Base => 16); New_Line; Put ("K1_Mask_On = "); IO.Put (K1_Mask_On, Base => 16); New_Line; X1 := I and K1; X2 := I and K2; K1 := Shift_Right (K1, 1); K2 := Shift_Left (K2, 1); exit when K2 = 0; end; end loop; end Alternative; The idea behind your loop (I think) is to swap bits from either end from MSBit to LSBit with a prime number 'twist' in each step? You can do this using the above as the basis for that solution - all in 'Unsigned_32'. Cheers -- Martin