MySQL divided by Zero

Posted by Jetlogs @ 2:36 pm
Category: Humor, Web Development

From reading discussions of 4chan’s /prog/ boards, it seems that MySQL has some pretty weird behaviors when dividing by zero.

For example:

mysql> SELECT 1/0

will yield NULL, when the majority of other programming languages will have an error, or produce an NaN value (if float).

even two similar statements which both equate to a NULL because of division by zero are NOT equal:

mysql> SELECT NULL = NULL;

yields NULL

mysql> SELECT POW(0,-1) = 1/0;

yields NULL; consistent with MySQL behavior

mysql> SELECT POW(0,-1) <=> 1/0;

yields 0; inconsistent, 0 != NULL

and the weirdest part? take a look at this statement which uses the bitwise AND operator:

mysql> SELECT POW(0,-1) & POW(0,-1);

which would yield:
9223372036854775808

since x & x is equal to x
in short, according to MySQL,
1/0 = 9223372036854775808


No Comments »

No comments yet.

RSS Comment Feed Comments RSS |trackback TrackBack URI

Leave a comment

  • Archives

  • Donations

  • Social Bookmarks

  • Jetlogs.org
    Some Rights Reserved 2007
    Creative Commons License