Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Interesting numbers about hashing - 32 bits are clearly not enough

Author: Steffen Jakob

Date: 00:57:00 12/07/01

Go up one level in this thread


On December 06, 2001 at 18:15:27, Robert Hyatt wrote:

>On December 06, 2001 at 17:02:42, Slater Wold wrote:
>
>>On December 06, 2001 at 15:21:17, J. Wesley Cleveland wrote:
>>
>>>This problem is like the problem "How many people does it take before
>>>it is probable that two have the same birthday ?". The answer, which
>>>many people find suprising is 23. To calculate this, calculate the
>>>probability p, that two people have different birthdays = 364/365.
>>>Then calculate how many pairs of people n, you need before this is less
>>>than 1/2, p^n <.5. Then find the number of people g, which taken two at
>>>a time is >= n, g = n*(n-1)/2.
>>>
>>>The same method tells you how many different positions you can have
>>>before it is likely that two will have the same hash key.
>>>
>>>32 bits 77163
>>>48 bits 1.97536627683E+7
>>>64 bits 5.05693754118E+9
>>>
>>>
>>>Thanks to Cliff Leitch for providing a high precision freeware calculator.
>>
>>I agree.  It's time for 64 bits and integers.
>>
>>On Crafty right now, I cannot search for more than about 6 minutes a position,
>>or the node counter resets.  That's a bummer.
>
>
>This will be fixed in the next version.  Node counter is 64 bits.  And all
>uses of it are also 64 bits...  The only issue is going to be printing them
>out, which might take some minor source changes for windows.
>
>IE in GCC, %llu is the way to print an unsigned 64 bit int.  I will have to
>research what is needed for MSVC and then the commercial compilers for the
>various unix platforms, since the %ll was not included in the ANSI standard.

I am happy that I use C++ iostreams. How about encapsulating the printing of an
unsigned long long in a C++ function (the following implementation isnt very
good because you can use ullToString only once within the same context; it only
should demonstrate the idea). This should be portable:

wrapper.cpp (C++):
------------------
#include <iostream>
#include <sstream>
#include <string>

extern "C" {

	const char *ullToString(unsigned long long value) {
		static std::string str;
		std::ostringstream os;

		os << value;
		str = os.str();

		return str.c_str();
	}

}


demo.c (C):
-----------
#include <stdio.h>

extern const char *ullToString(unsigned long long value);

int main(int argc, char **argv) {
	printf("this is an unsigned long long: %s\n",
		ullToString(1234567890123));
}



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.