Aleksandar Donev wrote: >Hello, >Does anyone know of faster ways to interweave bits from 2 or 3 integers (the >total number of result bits being less than 32, say)? The obvious way of >looping over the bits and shifting them one by one is easy to do, but there >may be a faster trick. Also the reverse operation, breaking up a bit string >into "even" and "odd" bits? >Thanks, >Aleks > Some architectures have hardware instructions that will do arbitrary bit rearrangements within a word, of which your examples are special cases. If you don't have access to such systems, or require more portable code, try looking at the algorithms at www.hackersdelight.org for generalized bit compression and extraction, and then specialize the code for your case. Cheers, Bill -- Bill Long [log in to unmask] Fortran Technical Support & voice: 651-605-9024 Bioinformatics Software Development fax: 651-605-9142 Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120