Computer Chess Club Archives


Search

Terms

Messages

Subject: oups - or of course

Author: Gerd Isenberg

Date: 07:34:27 02/28/06

Go up one level in this thread


Yes, your approach is indeed also a nice trick to ripple the carry through
unwanted bits.

1.) or with the complement of the original set (d) to set all unwanted bits, so
    that a possible overflow walks trough
2.) increment and ripple the carry through unwanted bits
3.) reset all unwanted bits by anding with the original set (d)

Shame that i don't found it by myself ;-(

   n = ((n | ~d) + 1) & d;

due to the definition of the Two's complement == One's complement plus one,
it becomes:


   n = ((n | (-d-1)) + 1) & d;

Now it looks like the "or" may be simply replaced by add ;-)

   n = (n-d) & d;

Nice algebra!



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.