Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: boundschecking

Author: Severi Salminen

Date: 12:18:04 11/04/02

Go up one level in this thread


>>>__int64 rand64()
>>>{
>>>	int a,b,c,d,e;
>>>	a=rand();
>>>	b=rand()<<15;
>>>	c=rand()<<30;
>>>	d=rand()<<45;
>>>	e=rand()<<60;
>>>
>>>	return a^((__int64)b)^((__int64)c)^
>>>		((__int64)d)^((__int64)e);
>>>}
>>
>>Under most systems, d and e will be zero.

A few points. As Dieter said, the above is wrong, because of too late type
casts. Secondly why do you use XOR? Why not OR, the result is about the same? OR
has a definite sequence points and can be used like in your original rand64():

unsigned __int64 rand64()
{
    return (ui) rand()|(ui)rand()<<15|(ui)rand()<<30 //and so on...
}

The above should work in debug and release modes similarily. And you should read
the topic "precedence of operators" in C docs or search with google. That way
you can be sure when you need parentheses. Of course one should use parentheses
whenever that makes things look more logical.

>It still does not explain the crush that I have.

Oh, Uri is in love  ;)

>Movei does not use hash tables to prune the tree and it is not supposed to crush
>when it get bad numbers in the hash.
>
>It should only be slower because of bad order of moves but the new numbers that
>I get with your function when I only change signed to unsidned are almost the
>same as the old number so I do not believe that the numbers were
>0's.

Impossible to tell what is the cause. But by making the above corrections,
you'll be able to narrow it down step by step. 1st check if it is because of
hash tables and then start tracking it down. ASSERTS() would most likely help
here also. Very likely you have out of bound problem again. Or something
similar: uninitialize variable etc.

>I now compare the number in debug and release with your program(I only deleted
>unsigned because I used numbers that are not unsigned and I do not want to get
>new problems of translating unsigned to signed.

You WILL get problems when using too much signed. It is allways best to use
unsigned whenever possible because of what Dieter said.

Severi



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.