Следующий код поможет вам понять это:
public class Main {
public static void main(String[] args) {
System.out.println("Long.MAX_VALUE is " + Long.MAX_VALUE);
System.out.println("Math.pow(2, 63) is " + Math.pow(2, 63));
System.out.println("Math.pow(2, 63) - 1 is " + (Math.pow(2, 63) - 1));
System.out.println("(long)Math.pow(2, 63) is " + (long) Math.pow(2, 63));
System.out.println("(long)(Math.pow(2, 63) - 1) is " + (long) (Math.pow(2, 63) - 1));
if (9223372036854775807L < Math.pow(2, 63)) {
System.out.println("9223372036854775807L < Math.pow(2, 63)");
}
if (9223372036854775807L <= Math.pow(2, 63)) {
System.out.println("9223372036854775807L <= Math.pow(2, 63)");
}
if (9223372036854775807L <= Math.pow(2, 63) - 1) {
System.out.println("9223372036854775807L <= Math.pow(2, 63) - 1");
}
if (9223372036854775807L < (long) Math.pow(2, 63)) {
System.out.println("9223372036854775807L < (long)Math.pow(2, 63)");
}
if (9223372036854775807L <= (long) Math.pow(2, 63)) {
System.out.println("9223372036854775807L <= (long)Math.pow(2, 63)");
}
if (9223372036854775807L <= (long) Math.pow(2, 63) - 1) {
System.out.println("9223372036854775807L <= (long)Math.pow(2, 63) - 1");
}
if (9223372036854775807L <= (long) (Math.pow(2, 63) - 1)) {
System.out.println("9223372036854775807L <= (long)(Math.pow(2, 63) - 1)");
}
}
}
Вывод:
Long.MAX_VALUE is 9223372036854775807
Math.pow(2, 63) is 9.223372036854776E18
Math.pow(2, 63) - 1 is 9.223372036854776E18
(long)Math.pow(2, 63) is 9223372036854775807
(long)(Math.pow(2, 63) - 1) is 9223372036854775807
9223372036854775807L <= Math.pow(2, 63)
9223372036854775807L <= Math.pow(2, 63) - 1
9223372036854775807L <= (long)Math.pow(2, 63)
9223372036854775807L <= (long)(Math.pow(2, 63) - 1)