I'm a beginning programmer and I need a method that returns whether or not a double is an integer. The problem occurs when the number is too big for an int to hold.
Here's what I have:
private static boolean isInteger(double n){
int ni = (int) n;
double nd = (double) ni;
if (nd==n)
return true;
return false;
}
Say I put in like 143215890634.0. It will return false because the int can't store that many digits.
How can I allow the int(or another class) to store more digits or is there a better way to determine if a double is an int without comparing like this?
Thanks in advance!