Re: Fastest way to determine number is integer in plain Lua
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Fastest way to determine number is integer in plain Lua
- From: Michal Kolodziejczyk <miko@...>
- Date: 2008年11月07日 11:19:51 +0100
Alexander Gladysh wrote:
> Hi, list!
>
> Is there a plain Lua way to determine that given positive number is
> integer faster than doing something like a == math.floor(a)?
Do you mean faster execution or less typing?
I think in pure lua you will have to call a function from the math.*
library, and math.floor() is one of the fastest I think. Are you afraid
that it is not fast enough for you?
If you meant less typing, then define:
function isint(n)
return n==math.floor(n)
end
BTW, it works for positive and negative numbers as well.
Regards,
miko