Tsql-decimal, Numeric, Float & Real

Source: Internet
Author: User

There are several different types of numeric values in SQL Server, one of which is: exact type and approximate type . The approximate type actually has only two data types: float and real.

In our database design, if the design to need to store non-shaping values, many times we will be wondering exactly which of the following data types are needed:

    • Float
    • Real
    • Decimal
    • Numeric

It's really simple to say, but there are only two types of the above 4 types:

1) Float & Real

They are all numeric types that represent floating-point numbers, and are an approximate numeric representation, and Real is a special form of float.

The syntax of float is as follows:

Float (n): N is the number of bits (expressed in scientific notation) used to store the mantissa of the float value, which determines the precision and storage size of N. n is between 1 and 53 and defaults to 53

Value of N

Precision

Storage size

1–24

7-digit number

4 bytes

25-53

15-digit number

8 bytes

Real is equivalent to float (24)

2) Decimal & Numeric

Numeric is functionally equivalent to decimal, so we only talk about decimal. Decimal represents an exact numeric value with fixed precision and scale, and its syntax is as follows:

Decimal (P [, S])

P represents precision, that is, the total number of decimal digits that can be stored, including the number of digits to the left and right of the decimal point, which can make any value between 1 and 38, which defaults to 18

s represents the maximum number of decimal digits to the right of the decimal point

Tsql-decimal, Numeric, Float & Real

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.