Author: Miguel A. Ballicora
Date: 09:52:34 02/13/02
Go up one level in this thread
On February 13, 2002 at 11:39:52, Robert Hyatt wrote: >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. -32768 already overflew according to the standard (see my other post). Anyway, that is not my point in this message. >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. Of course, but you can have some control over what you add or substract in a chess program. However, negating a value in a negamax/negascout framework is something very common and most of the time is "out of sight" of the programmer and it will be a potential source of bugs if a number such as -32768 is allowed. It is a very ill number, because it is a valid negative number that does not have a valid counterpart on the positive side. When the people see short int y, x, z; y = x + z; Even if x and z have valid values the first question is "do I have an overflow"? but it is not as obvious that short int y, x; y = -x; might cause problems. Besides, there is no reason to have assimetric bounds in a chess program just because 2's complement arithmetic allows me. Regards, Miguel > >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.