content_image/800132.jpg
The scope of precision math for exact-value operations includes the exact-value data types (integer and DECIMAL  types) and exact-value numeric literals. Approximate-value data types and numeric literals are handled as floating-point numbers. 

Exact-value numeric literals have an integer part or fractional part, or both. They may be signed. Examples: 1 , .2 , 3.4 , -5 , -6.78 , +9.10 . 

Approximate-value numeric literals are represented in scientific notation with a mantissa and exponent. Either or both parts may be signed. Examples: 1.2E3 , 1.2E-3 , -1.2E3 , -1.2E-3 . 

Two numbers that look similar may be treated differently. For example, 2.34  is an exact-value (fixed-point) number, whereas 2.34E0  is an approximate-value (floating-point) number. 

The DECIMAL  data type is a fixed-point type and calculations are exact. In MySQL, the DECIMAL  type has several synonyms: NUMERIC , DEC , FIXED . The integer types also are exact-value types. 

The FLOAT  and DOUBLE  data types are floating-point types and calculations are approximate. In MySQL, types that are synonymous with FLOAT  or DOUBLE  are DOUBLE PRECISION  and REAL . 

## 12.25.2 DECIMAL Data Type Characteristics 

This section discusses the characteristics of the DECIMAL  data type (and its synonyms), with particular regard to the following topics: 

•Maximum number of digits 

•Storage format 

•Storage requirements 

•The nonstandard MySQL extension to the upper range of DECIMAL  columns 

The declaration syntax for a DECIMAL  column is DECIMAL( M , D ) . The ranges of values for the arguments are as follows: 

• M  is the maximum number of digits (the precision). It has a range of 1 to 65. 

• D  is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M . 

If D  is omitted, the default is 0. If M  is omitted, the default is 10. 

The maximum value of 65 for M  means that calculations on DECIMAL  values are accurate up to 65 digits. This limit of 65 digits of precision also applies to exact-value numeric literals, so the maximum range of such literals differs from before. (There is also a limit on how long the text of DECIMAL  literals can be; see Section 12.25.3, “Expression Handling” .) 

Values for DECIMAL  columns are stored using a binary format that packs nine decimal digits into 4 bytes. The storage requirements for the integer and fractional parts of each value are determined separately. Each multiple of nine digits requires 4 bytes, and any remaining digits left over require some fraction of 4 bytes. The storage required for remaining digits is given by the following table. 

<img src='content_image/800132.jpg'>

