Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Interesting answer to my rotation question from news:comp.algorithms

Author: Dann Corbit

Date: 20:45:39 06/06/02

Go up one level in this thread


On June 06, 2002 at 23:45:01, Dann Corbit wrote:

Err...
Make that news:comp.programming (and also news:sci.math in the crosspost)

>uint64 flip(uint64 a)
>{
>  a =  (a&0xf0f0f0f00f0f0f0f)
>      |(a&0x0f0f0f0f00000000)>>28
>      |(a&0x00000000f0f0f0f0)<<28;
>  a =  (a&0xcccc3333cccc3333)
>      |(a&0x3333000033330000)>>14
>      |(a&0x0000cccc0000cccc)<<14;
>  return (a&0xaa55aa55aa55aa55)
>        |(a&0x5500550055005500)>>7
>        |(a&0x00aa00aa00aa00aa)<<7;
>}
>
>uint64 rotate90(uint64 a)
>  a =  (a&0xf0f0f0f000000000)>>32
>      |(a&0x0f0f0f0f00000000)<<4
>      |(a&0x00000000f0f0f0f0)>>4
>      |(a&0x000000000f0f0f0f)<<32;
>  a =  (a&0xcccc0000cccc0000)>>16
>      |(a&0x3333000033330000)<<2
>      |(a&0x0000cccc0000cccc)>>2
>      |(a&0x0000333300003333)<<16;
>  a =  (a&0xaa00aa00aa00aa00)>>8
>      |(a&0x5500550055005500)<<1
>      |(a&0x00aa00aa00aa00aa)<<8
>      |(a&0x0055005500550055)>>1;
>  return a;
>}



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.