0

I have a formula where it should be taken into account just than, when the result is an integer (not float, not double, or other number types). So....is there a possibility to say: "If the result is not an integer, than..."?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Z.D.
  • 1
  • 2
  • Do you have a method that returns an `int`? Then you can't have any other type of variable there... You should [edit] to show some code – OneCricketeer Nov 09 '16 at 23:08
  • `1000 * 0.001` will not necessarily yield `1.0` and be equal to 1. So: `if (Math.abs(x - Math.round(x)) < 1E-14) { intish }`. – Joop Eggen Nov 09 '16 at 23:39

1 Answers1

0
 if(obj instanceof Integer) { 
     //this should do the job 
 }
Vojtech Ruzicka
  • 16,384
  • 15
  • 63
  • 66
XtremeBaumer
  • 6,275
  • 3
  • 19
  • 65