Computer Chess Club Archives


Search

Terms

Messages

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

Author: Sune Fischer

Date: 06:17:01 12/07/01

Go up one level in this thread


On December 07, 2001 at 09:00:27, Uri Blass wrote:
>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;
>}
>
>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

Don't you need to make a cast first:
__int64 b = x%((__int64)1000000);
?




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.