Jump to content

[Aporte] Detector de numeros decimales


Recommended Posts

Esta funcion detecta si un numero es decimal o entero.

function isNotDecimal(number) 
local _number = tonumber(number) 
local x = math.abs(_number) 
local y = math.abs(math.floor(_number)) 
    if (x - y) == 0 then 
    local st = true 
    return st 
    else 
    local st = false 
    return st 
    end 
end 

Devuelve true si no tiene decimales, devuelve false si contiene decimales

Uso:

int/float isNotDecimal (float number) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...