Informix® supports several
data types to store numbers:
Table 1. Informix numeric
data types
Informix data type |
Description |
SMALLINT |
16 bit signed integer |
INT / INTEGER |
32 bit signed integer |
BIGINT |
64 bit signed integer |
INT8 |
64 bit signed integer (replaced
by BIGINT) |
DEC / DECIMAL |
Equivalent to DECIMAL(16) |
DEC(p) / DECIMAL(p) |
Floating-point decimal number |
DEC(p,s) / DECIMAL(p,s) |
Fixed-point decimal number |
MONEY |
Equivalent to DECIMAL(16,2) |
MONEY(p) |
Equivalent to DECIMAL(p,2) |
MONEY(p,s) |
Equivalent to DECIMAL(p,s) |
REAL / SMALLFLOAT |
32-bit floating point decimal
(C float) |
DOUBLE PRECISION / FLOAT[(n)] |
64-bit floating point decimal
(C double) |
Solution
MySQL supports the following data
types to store numbers:
Table 2. MySQL numeric data types
MySQL data type |
Description |
DECIMAL(p) |
Stores whole numeric numbers up
to p digits (not floating point) |
DECIMAL(p,s) |
Maximum precision depends on MySQL
Version, see documentation. |
FLOAT[(M,D)] |
4 bytes variable precision |
DOUBLE[(M,D)] |
8 bytes variable precision |
SMALLINT |
16 bit signed integer |
INTEGER |
32 bit signed integer |
BIGINT |
64 bit signed integer |
Note: Before MySQL 5.0.3, the maximum range of
DECIMAL values is the same as for DOUBLE. Since MySQL 5.0.3, DECIMAL
can store real precision numbers as in Informix. However, the maximum number of
digits depends on the version of MySQL, see documentation for more
details. We strongly recommend that you make tests (INSERT+SELECT)
to check whether large decimals are properly inserted and fetched
back.