I found this weird problem in JS. I have some native bindings to a board game api that uses bitboards for representing the game state. I am trying to manipulate these bitboards in JS to display the result in a web-based GUI (using electron).
The 1s in the bitboard represent the position of the pieces. Here is an example:
const bitboard = 0b100000010000000000000000000000000000;
However, when I do bitboard >>= 1;, the value magically becomes 0b1000000000000000000000000000.
Runnable example:
const bitboard = 0b100000010000000000000000000000000000; // 0b is binary literal
console.log(bitboard.toString(2));
console.log((bitboard >> 1).toString(2)); // .toString(2) prints the number in binary
Edit: The same code works in Rust which is the language that I am using on the native side.