Menu

SQL Server FLOAT(N) Data Type

SQL Server FLOAT stores approximate binary floating-point values. Its optional n parameter specifies mantissa bits, not decimal digits. FLOAT(1) through FLOAT(24) use the same 4-byte representation (about 7 significant decimal digits); FLOAT(25) through FLOAT(53) use 8 bytes (about 15 digits). The default is FLOAT(53). REAL is a synonym for FLOAT(24).

Syntax

The syntax is:

FLOAT [ ( n ) ]

n must be from 1 through 53. SQL Server maps values 1–24 to FLOAT(24) and values 25–53 to FLOAT(53), so changing n within either range does not change storage size or approximate precision. See Microsoft’s FLOAT and REAL documentation.

Use Cases

Use FLOAT for scientific or engineering values when a wide range and approximate results are acceptable. Avoid it for financial values, exact decimal calculations, or equality checks. For fixed-precision decimal values, use DECIMAL or NUMERIC; use REAL when single-precision approximate storage is intended.

Examples

Example 1

Here is an example using FLOAT(4) to store an approximate sensor measurement:

CREATE TABLE SensorReading (
    ReadingID INT PRIMARY KEY,
    Measurement FLOAT(4) NOT NULL
);

INSERT INTO SensorReading (ReadingID, Measurement)
VALUES (1, 123.456789);

SELECT * FROM SensorReading;

Here n = 4 falls in the 1–24 range, so SQL Server treats FLOAT(4) as FLOAT(24). The 4 does not mean four decimal digits; this bucket uses 4 bytes and approximately 7 significant decimal digits.

Example 2

Here is an example using the FLOAT(N) data type to calculate the area of a circle:

DECLARE @Radius FLOAT(24) = 2.5;
DECLARE @PI FLOAT(24) = 3.14159265358979323846;
DECLARE @Area FLOAT(24);

SET @Area = @PI * POWER(@Radius, 2);

SELECT @Area;

This calculation uses approximate values. FLOAT(24) provides about 7 significant decimal digits, so its result can differ slightly from an exact decimal calculation.

Conclusion

FLOAT represents a wide range of values approximately. The parameter n selects one of two mantissa/storage buckets; it is not a count of decimal digits. For exact decimal behavior, use DECIMAL or NUMERIC, and choose the precision and scale required by the data.