[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work1) now available
- From: Luis Carvalho <lexcarvalho@...>
- Date: Wed, 10 Jul 2013 23:21:27 -0400
Hisham wrote:
> Random suggestion: how about a single function math.type() that
> returns the number subtype, "float" or "integer"?
>
> At the risk of over-engineering, it also occurs to me that some
> libraries may want to know whether they're running with 32 or 64 bit
> ints or floats. This function could return that info as well, perhaps
> as a second return value.
That's a good idea, and it could also be merged with debug.numbits (which
doesn't seem to be a debug function):
math.type = function (x)
if type(x) ~= "number" then return nil end
local f = math.isfloat(x) and "f" or "i"
return f, debug.numbits(f)
end
Another idea is to have an extended type function that returns this extra
information if the argument is a number:
local old_type = type
type = function (x)
local t = old_type(x)
if t ~= "number" then return t end
local f = math.isfloat(x) and "f" or "i"
return t, f, debug.numbits(f)
end
Cheers,
Luis
--
Computers are useless. They can only give you answers.
-- Pablo Picasso
--
Luis Carvalho (Kozure)
lua -e 'print((("lexcarvalho@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'