Expression Handling Leftover Digits Number of Bytes 5–6 3 7–9 4 For example, a  DECIMAL(18,9)  column has nine digits on either side of the decimal point, so the integer part and the fractional part each require 4 bytes. A  DECIMAL(20,6)  column has fourteen integer digits and six fractional digits. The integer digits require four bytes for nine of the digits and 3 bytes for the remaining five digits. The six fractional digits require 3 bytes. DECIMAL  columns do not store a leading  +  character or  -  character or leading  0  digits. If you insert +0003.1  into a  DECIMAL(5,1)  column, it is stored as  3.1 . For negative numbers, a literal  -  character is not stored. DECIMAL  columns do not permit values larger than the range implied by the column definition. For example, a  DECIMAL(3,0)  column supports a range of  -999  to  999 . A  DECIMAL( M , D )  column permits up to  M  -  D  digits to the left of the decimal point. The SQL standard requires that the precision of  NUMERIC( M , D )  be  exactly M  digits. For  DECIMAL( M , D ) , the standard requires a precision of at least  M  digits but permits more. In MySQL,  DECIMAL( M , D )  and NUMERIC( M , D )  are the same, and both have a precision of exactly  M  digits. For a full explanation of the internal format of  DECIMAL  values, see the file  strings/decimal.c  in a MySQL source distribution. The format is explained (with an example) in the  decimal2bin()  function. With precision math, exact-value numbers are used as given whenever possible. For example, numbers in comparisons are used exactly as given without a change in value. In strict SQL mode, for  INSERT  into a column with an exact data type ( DECIMAL  or integer), a number is inserted with its exact value if it is within the column range. When retrieved, the value should be the same as what was inserted. (If strict SQL mode is not enabled, truncation for  INSERT  is permissible.) Handling of a numeric expression depends on what kind of values the expression contains: If a numeric expression contains any strings, they are converted to double-precision floating-point values and the expression is approximate. Inserts into numeric columns are affected by the SQL mode, which is controlled by the  sql_mode system variable. (See Section 5.1.11, “Server SQL Modes” .) The following discussion mentions strict mode (selected by the  STRICT_ALL_TABLES  or  STRICT_TRANS_TABLES  mode values) and ERROR_FOR_DIVISION_BY_ZERO . To turn on all restrictions, you can simply use  TRADITIONAL  mode, which includes both strict mode values and  ERROR_FOR_DIVISION_BY_ZERO : SET sql_mode=’TRADITIONAL’; 2456 •Otherwise, the expression contains only integer values. The expression is exact and is evaluated using integer arithmetic and has a precision the same as  BIGINT  (64 bits). •If no approximate values are present, the expression contains only exact values. If any exact value contains a fractional part (a value following the decimal point), the expression is evaluated using DECIMAL  exact arithmetic and has a precision of 65 digits. The term “exact”  is subject to the limits of what can be represented in binary. For example,  1.0/3.0  can be approximated in decimal notation as .333... , but not written as an exact number, so  (1.0/3.0)*3.0  does not evaluate to exactly  1.0 . •If any approximate values are present, the expression is approximate and is evaluated using floating- point arithmetic. 12.25.3 Expression Handling