INFORMIX
Informix-ESQL/C Programmer's Manual
Chapter 5: Working with Numeric Data Types
Home Contents Index Master Index New Book

The int8 Library Functions

The following ESQL/C library functions are available to handle int8 data type numbers.

Function Name Description

ifx_getserial8()

Returns an inserted SERIAL8 value

ifx_int8add()

Adds two int8 numbers

ifx_int8cmp()

Compares two int8 numbers

ifx_int8copy()

Copies an int8 number

ifx_int8cvasc()

Converts a C char type value to an int8 type value

ifx_int8cvdbl()

Converts a C double type value to an int8 type value

ifx_int8cvflt()

Converts a C float type value to an int8 type value

ifx_int8cvint()

Converts a C int type value to an int8 type value

ifx_int8cvlong()

Converts a C long type value to an int8 type value

ifx_int8div()

Divides two int8 numbers

ifx_int8mul()

Multiplies two int8 numbers

ifx_int8sub()

Subtracts two int8 numbers

ifx_int8toasc()

Converts an int8 type value to a text string

ifx_int8todbl()

Converts an int8 type value to a C double type value

ifx_int8toflt()

Converts an int8 type value to a C float type value

ifx_int8toint()

Converts an int8 type value to a C int type value

ifx_int8tolong()

Converts an int8 type value to a C long type value

ifx_getserial8()

The ifx_getserial8() function returns the SERIAL8 value of the last inserted row into an int8 host variable.

Syntax

Usage

Use the ifx_getserial8() function after you insert a row that contains a SERIAL8 column. The function returns the new SERIAL8 value in the int8 variable, serial8_val, which you declare. If the INSERT statement generated a new SERIAL8 value, the serial8_val points to a value greater than zero. A SERIAL8 value of zero or null indicates an invalid INSERT; the INSERT might have failed or might not have been performed.

Example

ifx_int8add()

The ifx_int8add() function adds two int8 type values.

Syntax

Usage

The sum can be the same as either n1 or n2.

Return Codes

0

The operation was successful.

-1284

The operation resulted in overflow or underflow.

ifx_int8cmp()

The ifx_int8cmp() function compares two int8 type numbers.

Syntax

Return Codes

-1

The first value is less than the second value.

0

The two values are identical.

1

The first value is greater than the second value.

INT8UNKNOWNW

Either value is null.

ifx_int8copy()

The ifx_int8copy() function copies one int8 structure to another.

Syntax

The ifx_int8copy() function does not return a status value. To determine the success of the copy operation, look at the contents of the int8 structure to which the target argument points.

ifx_int8cvasc()

The ifx_int8cvasc() function converts a value held as printable characters in a C char type into an int8 type number.

Syntax

Usage

The character string, strng_val, can contain the following symbols:

The strng_val character string should not contain a decimal separator or digits to the right of the decimal separator. The ifx_int8svasc() function truncates the decimal separator and any digits to the right of the decimal separator. The ifx_int8cvasc() function ignores leading spaces in the character string.

GLS
When you use a nondefault locale (one other than U.S. English), ifx_int8cvasc() supports non-ASCII characters in the strng_val character string. For more information, see the
Informix Guide to GLS Functionality.

Return Codes

0

The conversion was successful.

-1213

The string has non-numeric characters.

-1284

The operation resulted in overflow or underflow.

ifx_int8cvdbl()

The ifx_int8cvdbl() function converts a C double type number into an int8 type number.

Syntax

Return Codes

0

The conversion was successful.

<0

The conversion failed.

ifx_int8cvdec()

The ifx_int8cvdec() function converts a decimal type value into an int8 type value.

Syntax

Return Codes

0

The conversion was successful.

<0

The conversion failed.

ifx_int8cvint()

The ifx_int8cvint() function converts a C int type number into an int8 type number.

Syntax

Return Codes

0

The conversion was successful.

<0

The conversion failed.

ifx_int8cvlong()

The ifx_int8cvlong() function converts a C long type value into an int8 type value.

Syntax

Return Codes

0

The conversion was successful.

<0

The conversion failed.

ifx_int8div()

The ifx_int8div() function divides two int8 type values.

Syntax

Usage

The quotient can be the same as either n1 or n2.

Return Codes

0

The operation was successful.

-1202

The operation attempted to divide by zero.

ifx_int8mul()

The ifx_int8mul() function multiplies two int8 type values.

Syntax

Usage

The product can be the same as either n1 or n2.

Return Codes

0

The operation was successful.

-1284

The operation resulted in overflow or underflow.

ifx_int8sub()

The ifx_int8sub() function subtracts two int8 type values.

Syntax

Usage

The difference can be the same as either n1 or n2.

Return Codes

0

The subtraction was successful.

-1284

The subtraction resulted in overflow or underflow.

ifx_int8toasc()

The ifx_int8toasc() function converts an int8 type number to a C char type value.

Syntax

Usage

If the int8 number does not fit into a character string of length len, ifx_int8toasc() converts the number to an exponential notation. If the number still does not fit, ifx_int8toasc() fills the string with asterisks. If the number is shorter than the string, ifx_int8toasc() left-justifies the number and pads it on the right with blanks.

Because the character string that ifx_int8toasc() returns is not null terminated, your program must add a null character to the string before you print it.

GLS
When you use a nondefault locale (one other than U.S. English), ifx_int8toasc() supports non-ASCII characters in the strng_val character string. For more information, see the
Informix Guide to GLS Functionality.

Return Codes

0

The conversion was successful.

-1207

The converted value does not fit into the allocated space.

ifx_int8todbl()

The ifx_int8todbl() function converts an int8 type number into a C double type number.

Syntax

Usage

The floating-point format of the host computer can result in loss of precision in the conversion of an int8 type number to a double type number.

Return Codes

0

The conversion was successful.

<0

The conversion failed.

ifx_int8todec()

The ifx_int8todec() function converts an int8 type number into a decimal type number.

Syntax

Return Codes

0

The conversion was successful.

<0

The conversion was not successful.

ifx_int8toint()

The ifx_int8toint() function converts an int8 type number into a C int type number.

Syntax

Usage

The ifx_int8toint() library function converts an int8 value to a C integer. The size of a C integer depends upon the hardware and operating system of the computer you are using. Therefore, the ifx_int8toint() 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 int8 values to larger integers, use the ifx_int8tolong() library function.

Return Codes

0

The conversion was successful.

<0

The conversion failed.

ifx_int8tolong()

The ifx_int8tolong() function converts an int8 type number into a C long type number.

Syntax

Return Codes

0

The conversion was successful.

-1200

The magnitude of the int8 type number is greater than 2,147,483,647.




Informix-ESQL/C Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.