Author: Sune Fischer
Date: 07:51:16 12/07/01
Go up one level in this thread
On December 07, 2001 at 10:44:43, Miguel A. Ballicora wrote:
>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
You still need to pad with zeros in between if for instance b<GIGA/1000 (3
zeros), so the loops he made is probably better.
-S.
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.