lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 23/04/14 12:04, Christopher Berardi wrote:
> 
> Is there a way to determine if a number is an integer or a float? For example,
> 
>     x = 4 // 2   -- this will be an integer
> 		y = 2.5      -- this will be a float
> 		type(x)      -- number
> 		type(y)      -- number
> 		isInteger(x) -- true
> 		isInteger(y) -- false
> 		isFloat(x)   -- false
> 		isFloat(y)   -- true
> 
> Is there a function that acts like isInteger or isFloat? Or, is there another
> way to tell if a number is of one species or the other?
> 
> 
> 
> P.S. - 5.3.0-work2 built fine on Fedora 19 x86_64 with gcc 4.8.2.
> 

The maths library added a new function to reveal this information[1].

[1] http://www.lua.org/work/doc/manual.html#pdf-math.type
-- 
Liam

Attachment: signature.asc
Description: OpenPGP digital signature