6 ms·
In SQL, if you divide by zero, you get a NULL. If you divide by NULL, you get NULL (any operation involving a NULL yields NULL, even GROUP BY). I call it "a bla
by alganet 2y ago
In SQL, if you divide by zero, you get a NULL. If you divide by NULL, you get NULL (any operation involving a NULL yields NULL, even GROUP BY). I call it "a black hole zero", if it touches anything, that thing becomes a black hole zero.
Some languages will wrap division by zero in a special type, a NaN (not a number). You can then reason on top if that NaN if you want to.
So, in a sense, there are some people already doing practical stuff with substituting /0 for a new symbol.
- kaoD 2y agoDoes it? Under SQL standard or what engine? At least Postgres raises when dividing by zero.
- alganet 2y agoYou're right about division by zero. From SQL92: 4) The dyadic arithmetic operators <plus sign>, <minus sign>, <as- terisk>, and <solidus> (+, -, *, and /, respectively) specify addition, subtraction, multiplication, and division, respec- tively. If the value of a divisor is zero, then an exception condition is raised: data exception-division by zero. However, the "any operation involving NULL yields NULL" is standard: 1) If the value of any <numeric primary> simply contained in a <numeric value expression> is the null value, then the result of the <numeric value expression> is the null value. https://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt https://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt So, dividing by NULL is allowed and yields NULL. Dividing by zero yielding NULL is non-standard (I used it though).