Problems with extreme float values
Posted by: Steve Appling
Date: July 30, 2008 11:34AM

MySQL w/ Connector/J 5.1.6 doesn't seem to handle the limit cases for float values well. I am testing this against a column of type "FLOAT" using the innodb engine with sql_mode=TRADITIONAL.

Using a prepared statement to insert Float.MAX_VALUE into a column results in SQLException:
Numeric value out of range message from server: "Out of range value adjusted for column 'c1' at row 1"

Using a prepared statement to insert Float.POSITIVE_INFINITY results in SQLException:
Unknown column 'Infinity' in 'field list'

Using a prepared statement to insert Float.NAN results in SQLException:
Unknown column 'NaN' in 'field list'


Trying to use a normal statement to more manually insert infinity (using quoted value) like this : INSERT INTO test_limit (c1) VALUES ('Infinity') results in SQLException:
Data truncated for column 'c1' at row 1


How can I store any of these valid float values in a float column? I thought the float datatype could hold any IEEE 754 4 byte value. Is this a bug or am I doing something wrong?

Options: ReplyQuote


Subject
Written By
Posted
Problems with extreme float values
July 30, 2008 11:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.