Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about optimizing code - puh Heiner is fast!

Author: Gerd Isenberg

Date: 13:50:24 07/08/03

Go up one level in this thread


On July 08, 2003 at 14:33:21, Reinhard Scharnagl wrote:

>Hi,
>
>>lets see whether Reinhard's code will do even better...
>
>the most time consuming process would be to produce
>such test numbers, better done before stopping any time.
>
>XORing three random numbers should produce a byte stream
>with an average of two bits set (instead of 1.27405)
>within a byte.
>
>But I am convinced even using this higher bit-rate for my
>proposed solution to be more effective, even without GOTOs.

Hi Reinhard,

see
http://www.talkchess.com/forums/1/message.html?305484

Gerd

>
>And the code is not that much cryptic.
>
>do {
>  switch (number) {
>    cases [all odd numbers (with 0x01 matching)]:
>      /* commands bit-0 */
>      number &= ~0x01; break;
>    cases [all numbers left with 0x02 matching]:
>      /* commands bit-1 */
>      number &= ~0x02; break;
>    cases [all numbers left with 0x04 matching]:
>      /* commands bit-2 */
>      number &= ~0x04; break;
>    case 0x08: case 0x18: case 0x28: case 0x38:
>    case 0x48: case 0x58: case 0x68: case 0x78:
>    case 0x88: case 0x98: case 0xa8: case 0xb8:
>    case 0xc8: case 0xd8: case 0xe8: case 0xf8:
>      /* commands bit-3 */
>      number &= ~0x08; break;
>    case 0x10: case 0x30: case 0x50: case 0x70:
>    case 0x90: case 0xb0: case 0xd0: case 0xf0:
>      /* commands bit-4 */
>      number &= ~0x10; break;
>    case 0x20: case 0x60: case 0xa0: case 0xe0:
>      /* commands bit-5 */
>      number &= ~0x20; break;
>    case 0x40: case 0xc0:
>      /* commands bit-6 */
>      number &= ~0x40; break;
>    case 0x80:
>      /* commands bit-7 */
>      number &= ~0x80; break;
>    case 0x00: default:
>      number  =  0x00; break;
>  }
>} while (number);
>
>
>Reinhard



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.