SQL Server data types: float, real, money, decimal, numeric

Source: Internet
Author: User

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 synonymRealIsFloat (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 valueN

Real

-3.40e + 38 to-1.18e-38, 0 and 1.18e-38 to 3.40e + 38

4 BYT

float [ ( n ) ]

WhereNIs the number of bits that are used to store the mantissa ofFloatNumber in scientific notation and, therefore, dictates the precision and storage size. IfNIs specified, it must be a value1And53. The default valueNIs53.

NValue 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] )]

AreDecAndDec (P,S).NumericIs functionally equivalentDecimal.

 

(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.

 

DecimalFixed precision and scale numbers. When maximum precision is used, valid values are from-10 ^ 38 + 1 through 10 ^ 38-1. The ISO synonymsDecimalP (precision) the maximum total number of decimal digits that can be stored, both to the left and to the right of the decimal point. the precision must be a value from 1 through the maximum precision of 38. the default precision is 18.SThe maximum number of decimal digits that can be stored to the right of the decimal point. scale must be a value from 0 throughP

 

Money and smallmoney

Data Types that represent monetary or currency values.

The Money And Smallmoney Data types are accurate to a ten-thousandth of the monetary units that they represent.
Data Type   Range Storage

Money

 

-From 922,337,203,685,477.5808 to 922,337,203,685,477.5807

8 bytes

Smallmoney

 

-From 214,748.3648 to 214,748.3647

4 bytes

 

 

Float indicates a floating point number (non-exact number). It can receive a floating point number expressed in scientific notation. The float type is special. You can even specify the precision for the float type. Avoid using it in practical applications.

Float Equal Or Not equal In Greater Or Less The condition is correct.

We recommend that you use the money data type for money-related purposes.
Decimal is recommended when the data is large, the precision is required to be high, or the accuracy of the calculation results is controlled. Decimal and numeric are basically the same.

Related Article

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.