How to find if a number or fraction is an integer in Java?
I did some research before but struggle to apply them. I want to do something like this:
if (x is int){
//commands
}
How to find if a number or fraction is an integer in Java?
I did some research before but struggle to apply them. I want to do something like this:
if (x is int){
//commands
}
You should use something like this:
if((x%1)==0){
//do stuff
}
This checks to see if the decimal part of the number is zero.