[X]

Dividing By Zero

luljs still works

Divide by zero and nothing throws.

In 2026: Still works. Floating point has signed infinities and a NaN, so 1/0 is Infinity, -1/0 is -Infinity, and 0/0 is NaN. None of them throws. Code that assumes division is safe can carry an Infinity or a NaN a long way before anything looks wrong.

Where it came from: IEEE 754 defines signed infinities and NaN, so division by zero yields a value instead of an error, per MDN's division page. MDN

<script>
document.write('<p><code>1 / 0</code> is <b>' + (1 / 0) + '</b></p>');
document.write('<p><code>-1 / 0</code> is <b>' + (-1 / 0) + '</b></p>');
document.write('<p><code>0 / 0</code> is <b>' + (0 / 0) + '</b></p>');
</script>
sandboxed demo · breaks nothing but itselfrestart

More in luljs

all 63 in luljs › · the whole library ›