Quantcast
Channel: Tech Notes » mysql
Viewing all articles
Browse latest Browse all 6

MySQL and Negative Infinity

$
0
0

mysql

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.


Viewing all articles
Browse latest Browse all 6

Trending Articles