lua-users home
lua-l archive

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

5/0 performs a floating-point division. IEEE 754 defines x/0 to be either inf (math.huge), -inf (-math.huge) or nan, depending on whether x is > 0, < 0 or = 0. Lua complies with this and doesn't throw an error.

5//0 on the other hand is an integer division. Lua is free to define what should happen here.

On 14.06.23 15:41, aman agrawal wrote:

Can anyone please tell me why we don't return an error for (5/0)? For (5//0), we return an error. I checked that we don't have any check for divisor value, but in luaV_idiv(), we check the divisor value.
Best Regards
Aman Agrawal