Check whether a float number contains decimals or not

decimal, floating-point

Solution

Using modulus will work:

if(num % 1 != 0) do something!
// eg. 23.5 % 1 = 0.5

Problem

How can I check whether a float number contains decimals like 2.10, 2.45, 12382.66 and not 2.00 , 12382.00. I want to know if the number is "round" or not. How can I do that programmatically?

Original source

Related problems