xxxxxxxxxx
if(x == (int)x){
println("x is an integer");
}
xxxxxxxxxx
function isInt(num) {
return num % 1 === 0;
}
console.log(isInt(4)); // true
console.log(isInt(12.2)); // false
console.log(isInt(0.3)); // false
xxxxxxxxxx
//"% (modulo)" calulates the remainder when the value on the left is divided by the value on the right
float number = 20;
if(number%1 == 0){
println("It is an integer");
} else {
println("It is not an integer");
}
xxxxxxxxxx
float number = 22.33;
if(number%1 == 0){
println("It is an integer");
} else {
println("It is not an integer");
}