Jump to content

Detect division by zero: Difference between revisions

→‎{{header|Lua}}: For 0/0 Lua returns -nan
(→‎{{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:
 
=={{header|Lua}}==
Lua, like Javascript, does not error on DIVIDE-BY-ZERO, but returns infinity, -infinity or -infinitynan. So:
 
<lang lua>local function div(a,b)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.