Approximate Numeric Datatypes

Approximate numeric datatypes store floating-point numbers like fractions where an approximation must be made. For instance, an accurate number, per se, cannot be stored for 1/3, because the decimal point for 3 continues on endlessly. Table A-2 lists approximate numeric datatypes. There are synonyms for a few of these types. DOUBLE and REAL are synonyms for DOUBLE PRECISION. However, if the SQL mode for the server has the REAL_AS_FLOAT option enabled, REAL is a synonym for FLOAT. For FLOAT, a level of precision may be specified. It may be from 0 to 24 for single-precision floating-point numbers and from 25 to 53 for double-precision floating-point numbers. If a precision isn’t given with FLOAT, a single-precision floating point is assumed. With DOUBLE, if UNSIGNED is specified, negative values are not allowed.

Table A-2. Approximate numeric datatypes

FLOAT( precision ) [UNSIGNED] [ZEROFILL]

 

FLOAT[(width,digits)] [UNSIGNED] [ZEROFILL]

 

-3.402823466E+38 to -1.175494351E-38

0

1.175494351E-38 to 3.402823466E+38

DOUBLE PRECISION[(width,digits)] [UNSIGNED] [ZEROFILL]

 

-3.402823466E+38 to -1.175494351E-38

0

1.175494351E-38 to 3.402823466E+38

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.