0

Right now, I am working on a chess engine, which stores each different representations of the board in 64bits, which I store in a long variable. Example:

private long wKing = 0b000000000000000000000000000000000000000000000000000000001000;

The problem is, I am when I go to print it out, I instead am given the value on the bit sequence(8), not the actual sequence. Here is my print statement:

System.out.println(wKing);

How can I print this out so that it gives me the sequence instead, so i can use it for testing and printing out a representation of the board in the future? Thank you.

  • Try `System.out.println(Long.toBinaryString(wKing));` ? Also this might help too: https://stackoverflow.com/questions/10401263/howto-print-long-in-binary – Marius Jaraminas Feb 25 '21 at 22:09

1 Answers1

0

You can use Long.toBinaryString.

System.out.println(Long.toBinaryString(wKing));

TechnoSam
  • 578
  • 1
  • 8
  • 23