Udostępnij za pośrednictwem


float and real (Transact-SQL)

Approximate-number data types for use with floating point numeric data. Floating point data is approximate; therefore, not all values in the data type range can be represented exactly.

[!UWAGA]

The ISO synonym for real is float(24).

Data type

Range

Storage

float

- 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308

Depends on the value of n

real

- 3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38

4 Bytes

Ikona łącza do tematu Transact-SQL Syntax Conventions

Syntax

  • float [ (n) ]
    Where n is the number of bits that are used to store the mantissa of the float number in scientific notation and, therefore, dictates the precision and storage size. If n is specified, it must be a value between 1 and 53. The default value of n is 53.

    nvalue

    Precision

    Storage size

    1-24

    7 digits

    4 bytes

    25-53

    15 digits

    8 bytes

[!UWAGA]

SQL Server treats n as one of two possible values. If 1<=n<=24, n is treated as 24. If 25<=n<=53, n is treated as 53.

The SQL Server float[(n)] data type complies with the ISO standard for all values of n from 1 through 53. The synonym for double precision is float(53).

Converting float and real Data

Values of float are truncated when they are converted to any integer type.

When you want to convert from float or real to character data, using the STR string function is usually more useful than CAST( ). This is because STR enables more control over formatting. For more information, see STR (Transact-SQL) and Built-in Functions (Transact-SQL).

Conversion of float values that use scientific notation to decimal or numeric is restricted to values of precision 17 digits only. Any value with precision higher than 17 rounds to zero.

Zobacz także

Odwołanie

ALTER TABLE (Transact-SQL)

CAST and CONVERT (Transact-SQL)

CREATE TABLE (Transact-SQL)

Data Types (Transact-SQL)

DECLARE @local\_variable (Transact-SQL)

SET @local\_variable (Transact-SQL)

Koncepcje

Data Type Conversion (Database Engine)