Floating Point Types
suggest changeFLOAT and DOUBLE represent approximate data types.
| Type | Storage | Precision | Range |
|---|---|---|---|
FLOAT |
4 bytes | 23 significant bits, about 7 decimal digits | about 10^+/-38 |
DOUBLE |
8 bytes | 53 significant bits, about 16 decimal digits | about 10^+/-308 |
REAL is a synonym for DOUBLE unless the REAL_AS_FLOAT SQL mode is enabled. DOUBLE PRECISION is a synonym for DOUBLE.
Although MySQL also permits (M,D) qualifier, do not use it. (M,D) means that values can be stored with up to M total digits, where D can be after the decimal. Numbers will be rounded twice or truncated; this will cause more trouble than benefit.
Because floating-point values are approximate and not stored as exact values, attempts to treat them as exact in comparisons may lead to problems. Note in particular that a FLOAT value rarely equals a DOUBLE value.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents