user569125 user569125 - 4 months ago 14
Java Question

How to check whether input value is integer or float?

How to check whether input value is integer or float?

Suppose 312/100=3.12,Here i need check whether 3.12 is float or integer.

Answer

You should check that fractional part of the number is 0. Use

x==Math.ceil(x)

or

x==Math.round(x)

or something like that