Floating Point Doesn't Work in MySQL
From OpenFSG
Problem
The MySQL server on the FSG doesn't support floating point columns or computations. There are no errors, but values are not stored or retrieved correctly.
This is possibly caused by some staticly linked libraries that try to emulate floating point calculations in software. These are most likely not compatible with the FSG's implementation of using the kernel to catch floating point commands.
Steps to Repeat
- Navigate to phpmyadmin after turning on the MySQL server in the FSG's config pages
- Click the SQL button on the left panel to bring up the Query Window
- Paste this code and click "Go"
CREATE DATABASE TESTDB1; USE TESTDB1; CREATE TABLE TABLE1 ( REC_ID int(10) unsigned NOT NULL auto_increment, VAL_DOUBLE double default NULL, PRIMARY KEY (REC_ID) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO TABLE1 (REC_ID, VAL_DOUBLE) VALUES(NULL, "0"); INSERT INTO TABLE1 (REC_ID, VAL_DOUBLE) VALUES(NULL, "7"); INSERT INTO TABLE1 (REC_ID, VAL_DOUBLE) VALUES(NULL, "16");
4. Paste this code to view the contents of the table
SELECT * FROM TESTDB1.TABLE1
5. Result: All the double values are set to 1.79769270625887e+308
Work Arounds
In some scenarios, you can just use a char or varchar column in place of a float or double and then do the conversion to float on the client side.
