Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: private % lessons

Author: Gerd Isenberg

Date: 15:08:17 09/17/03

Go up one level in this thread


On September 17, 2003 at 14:17:03, Dieter Buerssner wrote:

>On September 17, 2003 at 09:47:10, Gerd Isenberg wrote:
>
>>Some output of this program,
>>reciprocal hexadecimal 64-bit constants close to 64K:
>>                  .....
>>                  63960          1064ED5513C1B
>>                  64050          105F079E386B9
>>                  64350          104B7DBC83589
>>                  64477          1043464BCB8B1
>>                  64545          103EE372781F1
>>                  64575          103CF4D30C411
>>                  64687          1035C2495533A
>>                  64779          102FDD8A195D1
>>                  64897          102854AB57AFF
>
>The last number has the smallest error in the range shown.
>
>>                  64944          10255657AABAE
>>                  65026          10201FFFBF7F9
>>                  65077          101CE3CC6F8C1

and this works very well for my pawn hashing with AND 0x0ffff.

>>                  65100          101B6EB892595
>>                  65520          1001001001002
>>                  65534          1000200040009
>>                  65535          1000100010002

this sucks for obvious pawn pattern reasons
- only 60% pawn hash hit rate with initial position!

>
>I can reproduce all numbers.
>I guess, you won't need my output anymore.

Yes, i don't need it anymore - thanks to Fortran!


>
>BTW. In my last posts, I rounded the floating point results to integer, but
>actually truncation is wanted. I have to puzzle about, why actually truncation
>is wanted, and not rounding of 2**64/i. It certainly has to do with the fact,
>that 11/4 is 3 and not 4 (which would be the closest result) in integer math.
>But then again, using the rounded result, multiplying it back and subtracting,
>if negative add the divisor should calculate the correct mod.
>But to think of the total correct thing, can make the head spin. Especially
>confusing I find that one uses + i in the denominator.
>
>Cheers,
>Dieter


              K = (2**64 + i - 1) / i

is a ceil (1 / i) fixed point division, rounding the fixed point quotient K to
the nearest integers greater than or equal to K (if your data resulution is good
enough :-)

As you already mentioned, for "a%i" with "a - ((K * a)/2**64)*i"
one has to correct negative numbers!

But for some a's and i's i got numbers up to 3 greater "i"!
E.g. for i = 49981 with K = 0x00014FAC00053EB1
and a = 26182082926361 or 0x000017cffdc09719
i got a result of 49984!

That stuff really makes head spin :-)

Cheers,
Gerd




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.