fork download
  1. class Main
  2. {
  3. public static void main (String[] args) {
  4. long x = 3037000499L;
  5. System.out.println(x * x); // 9223372030926249001
  6. System.out.printf("%.0f\n", (double)(x * x)); // 9223372030926249000
  7. System.out.printf("%.0f\n", Math.pow(x, 2)); // 9223372030926249000
  8. System.out.println((long)Math.pow(x, 2)); // 9223372030926248960
  9.  
  10. System.out.println(Math.pow(x, 2) >= x * x); // 64float compare, true
  11. System.out.println((long)Math.pow(x, 2) >= x * x); // 64int copmare, false
  12. }
  13. }
  14.  
Success #stdin #stdout 0.11s 48784KB
stdin
Standard input is empty
stdout
9223372030926249001
9223372030926249000
9223372030926249000
9223372030926248960
true
false