Put C # in detail: compromise and trade-offs, deconstruct the decimal operation in C,Digress
Before the beginning of the text, I would like to thank the blog Park for providing this outstanding platform. I am honored to have won the Microsoft MVP
Are exact data types, the first two can define their own lengths and decimal digits, and Money's definition is equivalent to Numric (19,4)Numeric (10,2)Indicates that the maximum can be 10 digits, but the 10 digits have 2 digits that are decimals
Decimal (numeric), money, and float (real) are all floating point data types in MSSQL.
Sort by storage range
Float (real)
Decimal (numeric)
Money
You can give priority to money on the amount of storage. If the amount is too large, use
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).
The cause of the problem: we are doing fund projects to generate a lot of money on the home page display home information requirements to remove the extra 0 because we in the database design when the query return data such as 18.100000 this form and
It's always strange why a decimal is added to the pre-defined data type of C #. Isn't float and double enough? I am going to dig it out today.
Floating Point Type
Name
CTS Type
De script ion
Significant Figures
Range
In the database, what fields are generally used for the amount type, and money is used in actual use. Why is it so useful? Why not use float or decimal?
So we need to talk about the story behind them.
The decimal point of money is four digits,
Comparison of NUMERIC and DECIMAL types in Mysql, numericdecimal
Decimal (numeric) is synonymous and used to precisely store values.
A decimal data type can store up to 38 numbers. All numbers can be placed on the right of the decimal point. The
It's been weird. Why is a decimal added to the predefined data types of C #, and is it enough to have float and double? Come and dig a hole today.
Floating-point type
Name
CTS Type
De script ion
Significant figures
Range
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.