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 place value.
The Number. isInteger() method returns true if a value is an integer of the datatype Number. Otherwise it returns false .
The is_float() function checks whether a variable is of type float or not. This function returns true (1) if the variable is of type float, otherwise it returns false.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With