Heh Gerd, is Ansi-C nowadays garantueeing that in 64 bits integers right shifting of more than 32 bits is garantueed 100% ok, instead of undefined?Gerd Isenberg wrote:While all scalar data types (char, short, int, long) in Java are signed, C distinguish signed and unsigned data types. In order to shift right with zeros from left, like Java >>>, you need to declare (or cast) the data to shift unsigned and use the same operator >> as for signed shifts, where the most significant bit (sign bit) is shifted from left.NaltaP312 wrote:Hi,
i'm trying to code the bishopAttack and rookAttack.
to compute index with rotated bitboard i use this with java
but in c, it is different.Code: Select all
int idx_down = (int) (pieces_45 >>> DIA_DOWN_SHIFT[sq]) & 63; int idx_up = (int) (pieces_315 >>> DIA_UP_SHIFT[sq]) & 63;
i think i must divide by 2 my integer the number return by DIA_DOWN_SHIFT[sq].
Thanks for any help.
Best regards
Yves
Typically one uses a typedefinition:orCode: Select all
typedef unsigned long long BitBoard;
Code: Select all
typedef unsigned long long U64;
It's not interesting what compilers practical do, but what the language defines as being defined.
Vincent