Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about an efficient way to change the bits of a number.

Author: Ricardo Gibert

Date: 08:39:05 07/27/03

Go up one level in this thread


On July 27, 2003 at 11:10:07, Ratko V Tomic wrote:

>>To compute b = a for mask m: b = (b&~m)|(a&m)   [untested]
>>
>>That's 4 operations. 3 if m is a constant when the "~" will optimized away.
>
>A quicker way (max 3 ops):
>
>  b^=(a^b)&m;

Neat.

My way may gain from parallelizing operations, while yours is sequential.
However, I suspect mine uses an extra register and this should cause it to be
slower than yours depending on the context in which it is used. It would be
interesting to benchmark the two.



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.