Author: Robert Hyatt
Date: 08:49:41 09/10/03
Go up one level in this thread
On September 10, 2003 at 08:45:22, Uri Blass wrote:
>I found that my program printed the numbers 0 and 1 when it did the following
>code without printing mistake or mistake1.
>
>zobpawnkey[hply]=zobpawn;
>if (nodes==663719)
>{
> if (zobpawnkey[hply]!=zobpawn)
> printf("mistake");
> if ((zobpawnkey[hply]&1)!=(zobpawn&1))
> printf("mistake1");
> printf(" %d %d ",(zobpawn&1),(zobpawnkey[hply]&1));
>}
>
>both zobpawn and zobpawnkey[hply] are __int 64 varaibles.
>
>How is it possible?
You forgot the \n for one thing. This means that the C library will buffer
up one or the other (or both) of the above, but without the \n, the buffer
won't be printed until you eventually output a \n character...
However, they should be printed sooner or later.
What if zobpawnkey[hply] = 1
and zobpawn = 1
The first if is false (they are equal, not not-equal) so you don't get
mistake. Then when you and both with 1, you get 1, and the second if is also
false so you don't get mistake1 either.
Either problem will do the trick.
>I guess that I cannot trust & of 64 bit varaible with number unless I do some
>casting like (int)(zobpawn&1) but I thought that at least I can
>expect program to give the same value when it calculate the same thing even if
>the calculation is wrong.
>
>Uri
This page took 0.01 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.