Menu

MySQL DOUBLE: Approximate Double-Precision Values

Updated on

MySQL DOUBLE stores approximate numeric values using eight bytes of double-precision storage. DOUBLE PRECISION is a synonym. Use it when the range or precision of single-precision FLOAT is insufficient and small rounding differences are acceptable. Neither type stores decimal values exactly; use DECIMAL for exact decimal quantities such as monetary amounts. See MySQL’s floating-point type reference.

Syntax

measurement DOUBLE

For maximum portability, MySQL recommends using FLOAT or DOUBLE PRECISION without a precision or digit count. The legacy DOUBLE(M,D) form is a nonstandard MySQL extension and is deprecated. It should not be used to request exact decimal scale. The UNSIGNED attribute for DOUBLE is also deprecated in current MySQL documentation.

Example: calculate with approximate values

CREATE TABLE sensor_readings (
    sensor_id INT NOT NULL,
    measurement DOUBLE NOT NULL
);

INSERT INTO sensor_readings (sensor_id, measurement)
VALUES (1, 123456789.123456);

The stored value is approximate, so arithmetic can produce a small difference from the decimal value as written. When comparing calculated values, select an application-appropriate tolerance instead of requiring exact equality. MySQL’s floating-point value guidance explains why exact comparisons can behave unexpectedly.

Choose DOUBLE, FLOAT, or DECIMAL

DOUBLE provides a wider range and greater precision than four-byte single-precision FLOAT, while both remain approximate. Use FLOAT when its smaller storage and lower precision meet the requirement; use DECIMAL for exact fixed-point values and a chosen decimal scale. See the MySQL DECIMAL and NUMERIC guide for precision and scale.