"MySQL" Decimal data type

Source: Internet
Author: User
1.float, double, decimal

float: Floating point type, 4 bytes, 32bit.

Double: two-precision, 8-byte, 64-bit

Decimal: Digital type, 128bit, no loss of precision, commonly used in bank account calculation. (28 significant digits)

2.decimal Instructions for use:

Decimal (A, B)

Parameter description

A specifies the maximum number of decimal digits that can be stored to the left and right of the specified decimal point, with a maximum precision of 38.
b Specifies the maximum number of decimal digits that can be stored to the right of the decimal point. The number of decimal digits must be a value from 0 to a. The default number of decimal digits is 0.

Note

The decimal data type is used in calculations that require very high precision, and these types allow the precision and counting methods of the specified numeric values as selection parameters. Precision here is the total number of valid digits saved for this value, and the Count method represents the number of digits after the decimal point. For example, the statement decimal (5,2) specifies that the stored value will not exceed 5 digits, and that there are 2 digits after the decimal point.

Another: float and double do arithmetic operations, the value overflow will not error, the accuracy will therefore have a loss. Decimal will directly error.

Money can be a more general representation of the amount, for convenience store commodities this is usually fixed to 2 digits after the decimal point, you can use decimal.

"MySQL" Decimal data type

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.