Floating point type in MySQL

Source: Internet
Author: User

MySQL supports float, double, and decimal floating point types. Float values are used to represent single-precision floating point values, while double values are used to represent double-precision floating point values.

Like integers, these types also have additional parameters: a display width indicator and a decimal point indicator. For example, the float () statement specifies that the displayed value is no more than 7 digits, and the decimal point is followed by three digits.

MySQL will automatically round the number of digits after the decimal point to the value closest to it and then insert it.

The decimal data type is used in computation with very high precision requirements. This type allows you to specify the precision and counting method of a value as the selection parameter. The precision here refers to the total number of valid numbers saved for this value, and the counting method indicates the number of digits after the decimal point. For example, the decimal () statement specifies that the stored value cannot exceed 7 digits, and the decimal point cannot exceed 3 digits.

Ignoring the decimal data type precision and counting method modifier will make MySQL database set the precision of all fields marked as this data type to 10, and the calculation method to 0.

The unsigned and zerofill modifiers can also be used by float, double, and decimal data types. And the effect is the same as that of the int data type.

Type description value range: float [(m, d)] minimum non-zero value: ± 1. 175494351e-38 double [(m, d)] minimum non-zero value: ± 2. 225074255072014e-308 decimal (M, d) variable; its value range depends on m and D

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.