Computer Chess Club Archives


Search

Terms

Messages

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

Author: Miguel A. Ballicora

Date: 07:44:43 12/07/01

Go up one level in this thread


On December 07, 2001 at 09:00:27, Uri Blass wrote:

>On December 07, 2001 at 01:46:57, Uri Blass wrote:
>
>>On December 07, 2001 at 00:22:19, Miguel A. Ballicora wrote:
>>
>>>On December 07, 2001 at 00:20:18, Miguel A. Ballicora wrote:
>>>
>>>sorry, I pressed enter too early
>>>
>>>int64tostring (long long x, char *s)
>>>{ unsigned int a = x/1000000;
>>>  unsigned int b = x%1000000;
>>>  if (x>1000000)
>>>     sprintf(s,"%d%d",a,b);
>>>  else
>>>     sprintf(s,"%d",b);
>>>  return s;
>>>}
>>>
>>>then you use
>>>
>>>long long x;
>>>char buffer[64]
>>>printf("nodes: %s\n",int64tostring(x,buffer));
>>>
>>>Miguel
>>
>>I may try it
>>Here is my way to print long numbers(I needed it to print perft 8 from the
>>initial position when mone is perft 8)
>>
>>
>>printf("      %d",mone/1000000);
>>	mone=mone-1000000*(mone/1000000);
>>	if (mone<100000) printf("0");
>>	if (mone<10000) printf("0");
>>	if (mone<1000) printf("0");
>>	if (mone<100) printf("0");
>>	if (mone<10) printf("0");
>>	printf("%d",mone);
>>
>>Uri
>
>I did not understand exactly what you do
>
>1)My program does not understand the meaning of long long
>
>I get error C2632: 'long' followed by 'long' is illegal
>I guess that you probably mean __int64 so I cahnged every long long to __int64

No, I meant long long because that's part of the dialect of GCC, which is
the one that Bob uses more often, I guess, since he says that develops in linux.
They are suppose to mean the same.

>2)I also do not understand how can you do return s when your function returns
>nothing so I changed the name to  from int64tostring that to only tostring and
>let it return char *

Because it was a quick and dirty illustration, I forgot a line. It was supposed
to be more like a pseudo code.

>
>3)I also changed unsigned int to __int64 because I get the following warning
>warning C4244: 'initializing' : conversion from '__int64 ' to 'unsigned int ',
>possible loss of data

That is a warning that should not matter in this practical case, however a cast
should be more appropiate.

>
>I got the following function but it simply does not work
>
>char * tostring (__int64 x, char *s)
>{ __int64 a = x/1000000;
>  __int64 b = x%1000000;
>  if (x>1000000)
>     sprintf(s,"%d%d",a,b);
>  else
>     sprintf(s,"%d",b);
>  return s;
>}

It should not work in this way. The idea is to split a number that is too big
to fit in an int in two int's, so you can print the two parts with a
"%d" that is suppose to be for an int, NOT for anything bigger (like __int64)

This should be a cleaner attempt, sorry but I cannot test it from where I
am writing. The final function should be written more carefully with asserts
etc. This example should be understood as an idea.

typedef __int64 UI64;  /* long long for GCC */
char *
int64tostring (UI64 x, char *s)
{
  enum { GIGA = 1000000000
  };
  unsigned int a = (unsigned int)(x/GIGA);
  unsigned int b = (unsigned int)(x%GIGA);
  if (x>GIGA)
     sprintf(s,"%d%d",a,b);
  else
     sprintf(s,"%d",b);        /* this solves the problem of the 0 in front */
  return s;
}

Regards,
Miguel


>
>I tested my program by the following code
>char buffer[64];
>__int64 mone;
>mone=(1<<30);
>printf("mone: %s\n",tostring(mone,buffer));
>
>and I get the wrong output 10730 when the right output should be 2^30=1073741824
>
>Uri



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.