Float and Real
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. 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 Byt |
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.
n value Precision Storage size 1-24
7 digits
4 bytes
25-53
15 digits
8 bytes
Decimal and Numeric
Numeric data types that have fixed precision and scale.
- [ (p[ , s] )] and numeric[ (p[ , s] )]
-
are dec and dec(p, s). numeric is functionally equivalent to decimal.
- (scale)
-
. Scale can be specified only if precision is specified. The default scale is 0; therefore, 0 <= s <= p. Maximum storage sizes vary, based on the precision.
Money and SmallMoney
Data types that represent monetary or currency values.
Data type | Range | Storage | |
---|---|---|---|
money |
-922,337,203,685,477.5808 to 922,337,203,685,477.5807 |
8 bytes |
|
smallmoney |
- 214,748.3648 to 214,748.3647 |
4 bytes |
decimal建议在数据较大,或要求精度较高,或对计算结果进行精度控制时使用。decimal和numeric基本没有什么不同。