Author: Robert Hyatt
Date: 08:39:52 02/13/02
Go up one level in this thread
On February 13, 2002 at 01:27:29, Miguel A. Ballicora wrote: > >Ok, I undestand. Anyway, it is not your case but I will complete the idea. >-32768 might break in any processor, even in twos complements. For instance, >suppose that you use 16 bits and you have > >i = -32768; > >when you try to do x = -i; x will not be what you expect, I will still be >-32768. In a chess program is quite likely that a score will be negated. Of >course you might be using 32 bits, but as soon as you try to store that as 16 >bits you might have a problem. Maybe not, but it is asking for a bug at one >point if one is not vigilant. Best is to avoid, as you do, the possitility of >having a score of -32768 at all. That will cause a problem for sure. But then so will -32767-2, or 32767+1, or any other combination of values that overflow the 16 bit storage you have chosen. I wouldn't call that something that "might break in any processor" just because of the overflow/underflow problem. It doesn't matter _what_ value you store, you can always find something to add to it or subtract from it that will produce a wrong answer. One simple solution is to simply add one more bit to the field in the hash table, then there isn't a problem. I do this in Crafty, and I also don't store - numbers at all, I add a large constant to make them all positive to get around the 2's complement sign extension stuff...
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.