C # numeric data includes decimal, double, and float. I forgot everything I learned before, and now I want to review it briefly. According to MSDN, the decimal type is a 128-bit floating point number. The data range is 1.01028to7.91028, and the precision is 28-29 digits. Adding m or M after a number indicates that it is a decimal type. Do
C # numeric data includes decimal, double, and float. I forgot everything I learned before, and now I want to review it briefly. According to MSDN, the decimal type is a 128-bit floating point number. The data range is 1.010 28 to 7.910 28, and the precision is 28-29 digits, adding m or M after a number indicates that it is of the decimal type. Do
C # numeric data includes decimal, double, and float. I forgot everything I learned before, and now I want to review it briefly.
According to MSDN,
The decimal type is a 128-bit floating point number, and the data range is ± 1. 0 × 10 −28 to ± 7. 9 × 1028, with a precision of 28-29 digits. Adding m or M after a digit indicates that it is of the decimal type.
Double is a 64-bit floating point number with a data range of ± 5. 0 × 10 −324 to ± 1. 7 × 10308, with a precision of 15-16 valid digits. Adding d or D after a digit indicates that it is of the double type. Normal numbers with decimal points are of the double type by default. If you want an integer to be processed as a double type, add d or D to the end. in contrast, the decimal type has higher precision than the double type, but the range is relatively small.
Float is a 32-bit floating point number with a data range of ± 1. 5 × 10 −45 to ± 3. 4 × 1038, with a precision of 7 digits. Adding f or F after a number indicates that it is of the float type. It can be seen that it has much lower precision than the decimal type, but the range is larger.
For the money type in sqlserver, it is an 8-bit data type with a data range of-922,337,203,685,477.5808 to 922,337,203,685,477.5807,
Smallmoney is 4-digit between-214,748.3648 and 214,748.3647.
There are also numeric types in sqlserver, that is, decimal and numeric. They are the same and have the specified precision (number of valid digits) and specification, the maximum range is-10 ^ 38 + 1 to 10 ^ 38-1.
The following table shows the relationship between precision and storage space:
| Precision |
Storage bits |
|
1-9 |
5 |
|
10-19 |
9 |
|
20-28 |
13 |
|
29-38 |
17 |