Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Compiler bug?

Author: Robert Hyatt

Date: 14:00:49 07/03/02

Go up one level in this thread


On July 03, 2002 at 16:09:37, Sune Fischer wrote:

>Hi quick question.
>
>// this one is "faulty":
>#define RANK64(r) (0x00000000000000FF<<(r<<3))  // r is 0-7
>

That long number is _not_ a 64 bit value.  If you cast the hex constant
to 64 bits, the shift amount doesn't need to be cast (and it might well be
more efficient that way as well).



>// this one works:
>#define RANK64(r) (0x00000000000000FF<<((UINT64)r<<3))  // r is 0-7
>
>Q: Why do need I to cast the shifting parameter also, it's always a number
>between 0 and 63, isn't that obvious to the compiler (msvc++ 6)?
>
>I get these bitboards with the first version, after 31 bits things get nutty:
>
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>xxxxxxxx
>
>--------
>--------
>--------
>--------
>--------
>--------
>xxxxxxxx
>--------
>
>--------
>--------
>--------
>--------
>--------
>xxxxxxxx
>--------
>--------
>
>xxxxxxxx
>xxxxxxxx
>xxxxxxxx
>xxxxxxxx
>xxxxxxxx
>--------
>--------
>--------
>
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>
>--------
>--------
>--------
>--------
>--------
>--------
>--------
>--------



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.