lua-users home
lua-l archive

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


I completely agree with making it well defined, but wonder if rounding towards -inf is the most expected behavior (or perhaps most consistent)?

My personal inclination would be round towards zero, because it would be the most consistent behavior; that is, for any integral value i, tointeger(i / n) == i // n

Roberto Ierusalimschy wrote:


Because we expect conversions from floats to ints to be infrequent
in Lua with integers, we took the "luxury" to make them well behaved
operations. (Always rounds towards minus infinte, raise an error if
number is out of range. We also removed several system-dependent tricks
that Lua used to speed up those conversions.)