Author: Robert Hyatt
Date: 06:53:00 09/23/99
Go up one level in this thread
On September 23, 1999 at 05:00:04, Andreas Stabel wrote:
>On September 22, 1999 at 15:25:16, Robert Hyatt wrote:
>
>>On September 22, 1999 at 14:32:00, David Eppstein wrote:
>>
>>>On September 22, 1999 at 13:36:11, Robert Hyatt wrote:
>>>>There is a problem doing this for me. 64 bit ints are not yet ANSI-standard.
>>>>If a compiler supports them, you can use them. But _if_ you want to print them,
>>>>portability becomes an issue. IE in gcc I can use %lld to print one and it
>>>>works just fine. But that breaks other compilers. If we can get a group that
>>>>can give me a working 'format specification' that works on each compiler that
>>>>supports this, I can perhaps #define something and switch the node counter to
>>>>a long long/_int64...
>>>
>>>What's wrong with
>>>
>>>void printlonglong(FILE f, long long x)
>>>{
>>> if (x > 9) printlonglong(f,x/10);
>>> putc(f,x%10 + '0');
>>>}
>>>
>>>?
>>
>>
>>That is fine for printing. But suppose you want to copy it to a string
>>(ie using sprintf()) instead... it just makes the code very messy since there
>>is no agreed-on format specification for 64 bit ints.
>
>This is approx. how I have done it in my program:
>
>#define BITBOARD __int64
>
>char * outdlong(BITBOARD oval)
>{
> BITBOARD h1, h2;
> int i, negflag;
> static char obuff[32];
>
> i = 30; negflag = 0;
> if (oval < 0) { negflag = 1; oval = -oval; }
> for (;;) {
> h1 = oval / 10;
> h2 = oval - (h1*10);
> obuff[i] = (char)(h2+ '0'); --i;
> if (h1 == 0) break;
> oval = h1;
> }
> obuff[31] = 0;
> if (negflag) obuff[i] = '-'; else ++i;
> return(&obuff[i]);
>}
>
>char outbuf[...]
>
>sprintf(outbuff,"something %s something ...",,,,outdlong(myvar),,,);
>
>Of course in this implementation you should be careful not to use the
>outdlong routine twice without copying the output string since the static
>variable obuff will be overwritten.
>
>Regards
>Andreas Stabel
that works, but you can't use it twice in one printf()... ie in my case, I
would need multiple 64 bit ints, one for nodes, one for evals done, one for
hash probes, one for pawn hash probes, several for search extensions... you
have to print such lists one entry at a time because of the static buffer you
use. I do this for "DisplayEvaluation()" and it is a headache...
But I suppose I have to resort to such a trick to make this work since the 9x
C specification will take a decade to get approved.. :)
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.