Computer Chess Club Archives


Search

Terms

Messages

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

Author: Ratko V Tomic

Date: 08:10:07 07/27/03

Go up one level in this thread


>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;



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.