The dectoint() function

The dectoint() function converts a decimal type number into a C int type number.

Syntax

mint dectoint(dec_val, int_val)
   dec_t *dec_val;
   mint *int_val;
dec_val
A pointer to the decimal structure that contains the value to convert to an mint type value.
int_val
A pointer to an mint variable to contain the result of the conversion.

Usage

The dectoint() library function converts a decimal value to a C integer. The size of a C integer depends on the hardware and operating system of the computer you are using; therefore, the dectoint() function equates an integer value with the SQL SMALLINT data type. The valid range of a SMALLINT is between 32767 and -32767. To convert larger decimal values to larger integers, use the dectolong() library function.

Return values

0
The conversion was successful.
<0
The conversion failed.
-1200
The magnitude of the decimal type number is greater than 32767.