Debugger error or Programmer error?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw, Ras, hgm, chrisw, Rebel, Ras

Mike Sherwin
Posts: 928
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Debugger error or Programmer error?

Post by Mike Sherwin »

This line of code for setting the e.p. bit for a white pawn move works.
p16 = (u64)(mts - mfs == 16) << (mfs + 8);
So for e2e4 this equates as 1ull << 20 which is correct.

However, for c7c5 this line of code does not work.
p16 = (u64)(mfs - mts == 16) << (mfs - 8);
It equates to 0ull << 42 which is incorrect.

I made sure that mfs and mts were correct in both cases. c7 50 and c5 34, (50 - 34 == 16) = true = 1.
It has to be a debugger error?

Thanks
Mike Sherwin
Posts: 928
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Debugger error or Programmer error?

Post by Mike Sherwin »

std::cout << mfs - mts << "\n";
p16 = (u64)(mfs - mts == 16) << (mfs - 8);
std::cout << p16 << "\n";

r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
e2e4
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . P . . .
. . . . . . . .
P P P P . P P P
R N B Q K B N R
c7c5
16
0
Mike Sherwin
Posts: 928
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Debugger error or Programmer error?

Post by Mike Sherwin »

std::cout << mts - mfs << "\n";
p16 = (u64)(mts - mfs == 16) << (mfs + 8);
std::cout << p16 << "\n";


r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
e2e4
16
1048576 (0X100000)
Mike Sherwin
Posts: 928
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Debugger error or Programmer error?

Post by Mike Sherwin »

It was programmer error, :oops:
s32 p16; I could have sworn I made that a u64.