Mysql – How to find the stored binary value of a DOUBLE value in MySQL

datatypesfloating pointinnodbMySQLstorage

Given the following table, backed by MySQL 5.7/InnoDB:

CREATE TABLE mytable(mydouble DOUBLE) SELECT 0.005 `mydouble`;

how can I find what exactly InnoDB is storing on the disk for the value 0.005?

I know that this varies depending on the architecture, so I'm looking for a methodology rather than a certain value. I'm a programmer/dba, so I'm handy with any tool, if required.

Best Answer

A (very) poor man's strategy is to simply:

  • create a table with a known float value
  • perform a hex dump of the table ibd file
  • test against a hypothesis of how the value is stored

I've tested against the IEEE754 format value, but couldn't identify the value.

I've created the table adding a string value in the same record as the float, and I've actually found that the float storage format is actually IEEE754, but it's little endian.