import java.math.BigInteger; public class CountMoves { public static void main(String[] args) { // Java uses only the low six bits of a long shift distance, so this is 1L << 0. long shifted = (1L << 64) - 1; System.out.println("(1L << 64) - 1 = " + shifted); // 2^64 does not fit in a long, so the cast pins it to Long.MAX_VALUE first. long rounded = (long) Math.pow(2, 64) - 1; System.out.println("Math.pow(2, 64) - 1 = " + rounded); // BigInteger has no ceiling. BigInteger exact = BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE); System.out.println("BigInteger = " + exact); // Or keep all 64 bits in a long and print them as unsigned. System.out.println("unsigned long = " + Long.toUnsignedString(-1L)); } }