Operations that involve a decimal value
SQL data type | ESQL/C data type |
---|---|
INTEGER | 4-byte integer |
SMALLINT | short integer |
DECIMAL | decimal |
MONEY | decimal |
FLOAT | double |
SMALLFLOAT | float |
When Informix® ESQL/C performs arithmetic operations on operands with numeric data types and one of the operands has a decimal value (an SQL data type of DECIMAL or the Informix® ESQL/C data type of decimal), Informix® ESQL/C converts each operand and the result to a decimal value.
- The p parameter is the precision, which is
the total number of significant digits in a real number.
For example, the number 1237.354 has a precision of seven.
- The s parameter is the scale, which is the
number of digits that represent the fractional part of the real number.
For example, the number 1237.354 has a scale of three. If the DECIMAL data type includes a scale parameter (DECIMAL(p,s)), it holds fixed-point decimal numbers. If the DECIMAL data type omits a scale parameter (DECIMAL(p)), it holds floating-point decimal numbers.
The Informix® ESQL/C decimal data type tracks precision and scale differently from the SQL DECIMAL data type. For simplicity, this section uses the format of the SQL DECIMAL data type to describe how Informix® ESQL/C performs data conversion for arithmetic operations that involve a decimal value. However, this same data-conversion information applies to arithmetic operations that involve the Informix® ESQL/C decimal host variable.