How to check whether input value is integer or float?

前端 未结 8 1089
庸人自扰
庸人自扰 2020-12-13 05:44

How to check whether input value is integer or float?

Suppose 312/100=3.12 Here i need check whether 3.12 is a float value or integer value, i.e., without any decimal

8条回答
  •  星月不相逢
    2020-12-13 06:22

    How about this. using the modulo operator

    if(a%b==0) 
    {
        System.out.println("b is a factor of a. i.e. the result of a/b is going to be an integer");
    }
    else
    {
        System.out.println("b is NOT a factor of a");
    }
    

提交回复
热议问题