MySQL float type range and precision confusion

Viewed 1984

I'm learning MySQL and having problem with float's range and precision.

From the mannual:

For FLOAT, the SQL standard permits an optional specification of the precision (but not the range of the exponent) in bits following the keyword FLOAT in parentheses. MySQL also supports this optional precision specification, but the precision value is used only to determine storage size. A precision from 0 to 23 results in a 4-byte single-precision FLOAT column. A precision from 24 to 53 results in an 8-byte double-precision DOUBLE column.

I created a table using this command

create table test (f_a float(23));

I'm having 4 confusions:

  1. what's the meaning of but not the range of the exponent in the mannual?
  2. I can execute insert into test values (1e38); without problems. Even if I type 38 digits it still works. But 39 digits or 1e39 will fail. So what's the meaning of this 38?
  3. How can I inspect the type conversion of f_a? When I execute desc test; the type of f_a is still float even after I inserted a 38 digits number into that column.
  4. So, what's the difference between range and precision on earth?
1 Answers
Related