FLOAT (TSQL Datatype)

Is a 16-bytes double-precision floating-point number (base 2).




+-2.2250738585072014e–308 to +-1.7976931348623158e308


This type can store numbers with 15 decimal significant digits.

As it is base 2, non-integer decimal numbers are not stored exactly. So, don’t use float to store currency and monetary values. Use numeric instead.

When you want to convert float to varchar, you can use FORMAT or STR to have more control on the formatting.

If result of an operation is NaN or Infinite, an error is raised.

Literal Float

Any literal number containing an exponent part e is parsed as a float type.

With RSQL, the suffix f forces any literal number to be parsed as float.


123f       -- RSQL only. Parsed as float literal.
123.50f    -- RSQL only. Parsed as float literal.


DECLARE @a FLOAT = 123e0;

PRINT @a + 45.6e-1;

PRINT 1e200 * 1e200;   -- result is Infinite, an error is raised

The result is:

<Arithmetic error. FLOAT is Infinite.>

Examples (accuracy)

PRINT 123e0 + 45.6e-1;              -- 'float'   literals
PRINT 123456789012345e0;            -- 'float'   literal
PRINT 1.7e0;                        -- 'float'   literal

PRINT 123.3e0 / 10000e0 * 10000e0;  -- calculation with 'float'
PRINT 123.3   / 10000   * 10000  ;  -- calculation with 'numeric'

The result is:

1.7                   <--- in fact, this 'float' is stored internally as 1.6999999999999999
123.29999999999998    <--- result with 'float'   is unaccurate
123.300000000000      <--- result with 'numeric' is accurate