Approximate Numeric Data

Approximate numeric data consists of numeric data preserved as accurately as the binary numbering system allows. Many floating-point values cannot be accurately represented in binary notation. For these numbers, it is necessary to store an approximation of the decimal number. Examples of these numbers are floating-point values ending in .3, .6, and .7. The IEEE 754 specification provides four rounding modes: round to nearest, round up, round down, and round toward zero. SQL Server uses round up. All are accurate to guaranteed precision but can result in slightly different floating-point values. Because the binary representation of a floating-point number may use one of many legal rounding schemes, it is impossible to reliably quantify a floating-point value. It is best to avoid referencing to floating-point columns in WHERE clauses.

These are the approximate numeric datatypes:

float[(n)]
Is a datatype that holds positive or negative floating-point numbers. Specify the binary precision with b, which must be from 1 through 15. If the binary precision is from 1 through 7, it is another name for the real datatype. If the binary precision is from 8 through 15, it is considered a synonym for the float datatype. By default, this column has a 15-digit precision. The range of positive values is approximately from 2.23E - 308 through 1.79E 308, zero can be stored, and the range of negative values is approximately from -2.23E - 308 through -1.79E 308. Storage size is 8 bytes. All arithmetic operations except modulo are available with float.

Data of type float can include an optional exponent. For float data with an exponential component, enter a number (with or without a decimal point and a positive or negative sign), followed by e or E, followed by an optionally signed integer. The value represented by a float is the product of the first number and 10 to the power of the second number.

real
Is a floating-point column similar to float. This column has 7-digit precision. The range of positive values is approximately from 1.18E - 38 through 3.40E 38, zero can be stored, and the range of negative values is approximately from -1.18E - 38 through -3.40E 38. Storage size is 4 bytes.