0

I initialized a double a with Math.pow(10,24). Now I need to convert double a to int b:

a = Math.pow(10,24)
int b = (int)a;
System.out.println(a);
System.out.println(b);

System prints out :

1.0E24
2147483647

This result is obviously not correct.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
plattfuß
  • 9
  • 2

1 Answers1

3

It's because Integer has limit INT_MAX - 2147483647

Invisible
  • 112
  • 1
  • 2
  • 13