MySQL data type--floating point and fixed-point type

Source: Internet
Author: User

MySQL data type byte meaning

Float (m,d) 4-byte single-precision floating-point, 8-bit precision,m is the total number of decimal digits, andD is the number of digits after the decimal point

Double (m,d) 8-byte dual-precision floating-point, 16-bit precision

Float (7,4) can be displayed as -999.9999,MySQL is rounded when the value is saved , and if 999.00009 is inserted, the result is 999.0001

The parameter m stores the total length of the number,while D is different, affecting the precision, the number of digits after the decimal point.
For example, if a field is defined as float (5,3), if a number of 123.45678 is inserted, the actual database is 99.999, because the integer and decimal digits exceed the limit length of 5 to take the maximum value of the decimal place.

If you enter 1.45678, the database is stored as 1.457 after the decimal point, and the number is truncated to 457.

Note: Be sure to note the length of the number, determine the maximum value of the stored m and D precision values

Fixed-point number (decimal)

Numeric ranges depend on values of M and D

Decimal (M,D) m must be greater than or equal to D

Floating-point types hold approximate values in the database, while the fixed-point type stores the exact values in the database.

The parameter m is the maximum number (precision) of the fixed-point type number, the range is 0~65,

d the number of digits to the right of the decimal point, range 0~30, but not more than M.
The calculation of the fixed-point number can be accurate to 65 digits.

MySQL data type--floating point and fixed-point 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.