C # And sqlserver digital data type Learning

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.