Detect division by zero: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: division by zero fixed (a/b, where b == 0 may be inf or -inf, so it is not enough to check if a/b == 1/0)) |
(→{{header|Lua}}: For 0/0 Lua returns -nan) |
||
Line 1,219: | Line 1,219: | ||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
Lua, like Javascript, does not error on DIVIDE-BY-ZERO, but returns infinity or - |
Lua, like Javascript, does not error on DIVIDE-BY-ZERO, but returns infinity, -infinity or -nan. So: |
||
<lang lua>local function div(a,b) |
<lang lua>local function div(a,b) |