MySQL floating-point type and fixed-point number type

Source: Internet
Author: User

In MySQL, floating-point numbers and fixed-points are used to represent decimals, and floating-point numbers include single-precision floating-point types (float) and double-precision floating-point types (double), with a fixed-point number of only decimal types. Both floating-point and fixed-point types can be represented by (M, N), where M is precision, which represents the total number of digits, and N is the scale that represents the number of decimal places.

(1) floating point and fixed point number: Floating point is the decimal point in the decimal position is not fixed, the point number refers to the decimal point in the position of the decimal is fixed
(2) Single-precision and double-precision: single-precision with 4 bytes to store, double-precision with 8 bytes to store, because of different storage bits, they can represent a different range of values, that is, the number of digits can be accurately represented is different.

Type name Description Storage requirements Signed Value Range Unsigned range of values
FLOAT Single-precision floating-point number 4 bytes -3.4028 ~-1.1754 0 and 1.1754 ~ 3.4028
DOUBLE Double-precision floating-point number 8 bytes -1.7976 ~-2.2250 0 and 2.2250 ~ 1.7976
DECIMAL Compressed "strict" fixed-point number m+2 bytes Not fixed Not fixed

MySQL floating-point type and fixed-point number type

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.