lua-users home
lua-l archive

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



On Nov 16, 2014, at 1:48 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:

I am trying to convert a floating point number to an int

Do you really need to convert from one subtype to another?
Or just remove the fractional part of a float, resulting in a float?
Note that a float may have an integral value but might not be convertible to
an int. What do you need to happen if that is the case?

Like Dirk said, it all depends on what the application needs.

The philosophy of integers in Lua 5.3 is that applications rarely need to
mix the two subtypes and will benefit from using them separately, even if
some code needs to be changed. When an application really needs to mix the
two subtypes, then that is a point where it needs to stop and think about
what really needs to be done.


I kinda-sorta get that, but if you follow your logic then I don’t really see them as “sub-types” but fully distinguished types. I think one area that could be better explained in the docs is the distinction between integers and integral values.

—Tim