UserToDelete Posted February 21, 2015 Share Posted February 21, 2015 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
Tomas Posted February 21, 2015 Share Posted February 21, 2015 Más simple con string.find , buen aporte. Link to comment
Otto Posted February 21, 2015 Share Posted February 21, 2015 · Hidden Hidden function isNotDecimal(number) return math.floor(number) == number end Igual recomiendo la forma contraria, es más sencilla de entender: function isDecimal(number) return math.floor(number) ~= number end Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now