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.6 required=5.0 tests=BAYES_00,FROM_WORDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8309f2bc055237c4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-11-11 18:07:05 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!europa.netcrusader.net!207.114.4.11!nntp.abs.net!ptdnetP!newsgate.ptd.net!nntp.flash.net!news.flash.net!not-for-mail From: "Ken Garlington" Newsgroups: comp.lang.ada References: <8u8v6n$b7o$1@nnrp1.deja.com> <2WTH$pdrCfOd@eisner.decus.org> <8ub6kt$6nd$1@nnrp1.deja.com> <8ubeq8$cgm$1@nnrp1.deja.com> <3A0D38E9.BB87D8CD@mindspring.com> <3A0D86EB.4FAFA2EF@acm.org> <3A0DF35D.729DDE15@mindspring.com> Subject: Re: Bit manipulation X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: Date: Sun, 12 Nov 2000 02:07:04 GMT NNTP-Posting-Host: 216.215.86.198 X-Complaints-To: abuse@flash.net X-Trace: news.flash.net 973994824 216.215.86.198 (Sat, 11 Nov 2000 20:07:04 CST) NNTP-Posting-Date: Sat, 11 Nov 2000 20:07:04 CST Organization: FlashNet Communications, http://www.flash.net Xref: supernews.google.com comp.lang.ada:2034 Date: 2000-11-12T02:07:04+00:00 List-Id: As I recall, there was also an implied desire to avoid a loop. How about: package Word_Bitstring is type Object is array (1 .. 32) of Boolean; pragma Pack(Object); function Swap (O : Object) return Object; end Word_Bitstring; package body Word_Bitstring is function Swap (O : Object) return Object is begin return O(32) & O(31) & O(30) & O(29) & O(28) & O(27) & O(26) & O(25) & O(24) & O(23) & O(22) & O(21) & O(20) & O(19) & O(18) & O(17) & O(16) & O(15) & O(14) & O(13) & O(12) & O(11) & O(10) & O(09) & O(08) & O(07) & O(06) & O(05) & O(04) & O(03) & O(02) & O(01); end Swap; end Word_Bitstring; Seems a little error prone, but it might be reasonably efficient. Try it and see! "Redryder" wrote in message news:3A0DF35D.729DDE15@mindspring.com... : Jeff, : It goes like this: BIT 0 to BIT 31, BIT 31 to BIT 0 , and so on. : John : : Jeff Carter wrote: : : > Redryder wrote: : > > : > > I need to swap the bits in a 32-bit word. : > : > I could perhaps be of more assistance if I knew what you mean by "swap : > the bits". : > : > -- : > Jeff Carter : > "I unclog my nose towards you." : > Monty Python & the Holy Grail :