
There are always subtle nuances to every computer language. Recently, I found the following NaN (not a number) nuance in Java:
Bad:
if (value == Double.NaN) // Do something...
Good:
if (Double.isNaN(value)) // Do something....

There are always subtle nuances to every computer language. Recently, I found the following NaN (not a number) nuance in Java:
Bad:
if (value == Double.NaN) // Do something...
Good:
if (Double.isNaN(value)) // Do something....

Storing and retrieving negative infinity in a MySQL database is accomplished by inserting an arbitrarily large negative number. Negative infinity is handy when storing default values in a database.
The following SQL statement is an example of inserting negative infinity:
INSERT INTO test(negative_infinity) VALUES('-1e500');
Here is the test table:
CREATE TABLE test ( negative_infinity DOUBLE NOT NULL ) ENGINE=INNODB character set utf8;
The value in the database is stored as the maximum negative value for the data type, double (-1.79769313486232e+308).
mysql> select * from test; +------------------------+ | negative_infinity | +------------------------+ | -1.79769313486232e+308 | +------------------------+ 1 row in set (0.00 sec)
In Java, the Double contsant for max infinity, directly correlates to the value stored by MySQL.