Is there any way of detecting if a number is a floating point?

Hey, I’m A_quisition

The title says everything

Search the forum before posting :wink:

Check the float section

i don’t know if this is the best method but i do:

floatNumber = 12.34

if floatNumber == math.round(floatNumber) then
    print(floatNumber .." is an integer number!")
elseif floatNumber ~= math.round(floatNumber) then
    print(floatNumber .." is a float number!")
else
    print(floatNumber .." is not a number!")
end

Expected output:

12.34 is a float number!

New method:

local FloatNumber = 2.5

if FloatNumber % 1 == 0 then
    print("FloatNumber is an integer")
else
    print("FloatNumber is a float")
end
1 Like