Computer Chess Club Archives


Search

Terms

Messages

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

Author: Uri Blass

Date: 08:20:57 12/07/01

Go up one level in this thread


On December 07, 2001 at 11:12:22, Sune Fischer wrote:

>Wups, reverse that, the logic was bad before.
>
>char *PrintInt64(long64 x, char *s)
>{
>int  MEGA=1000000;
>long64 a = x/((long64) MEGA);
>long64 b = x%((long64) MEGA);
>
>  if (a==0)
>  {
>     sprintf(s,"%d",b);
>     return(s);
>  }
>
>  if      (b<MEGA/100000)  sprintf(s,"%d00000%d",a,b);
>  else if (b<MEGA/10000)   sprintf(s,"%d0000%d",a,b);
>  else if (b<MEGA/1000)    sprintf(s,"%d000%d",a,b);
>  else if (b<MEGA/100)     sprintf(s,"%d00%d",a,b);
>  else if (b<MEGA/10)      sprintf(s,"%d0%d",a,b);
>  else if (b>=MEGA/10)     sprintf(s,"%d%d",a,b);
>  else sprintf(s,"Error in PrintInt64");
>
>  return(s);
>}

does not work
long64 is a mistake and when I try to use __int64
I get wrong ansewer when I try to print 2^31 by this function (I get -2^31)

I will use my program that seem to be simpler than it
I have also there a loop and not a list of if's

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.