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

The INT8 and SERIAL8 SQL Data Types

ESQL/C supports the SQL INT8 and SERIAL8 data types with the int8 data type. The int8 data type is a machine-independent method that represents numbers in the range -(263 -1) to 263-1.

For a complete description of the SQL data types INT8 and SERIAL8, see the Informix Guide to SQL: Reference. This section describes how to manipulate the ESQL/C data type, int8.

The int8 Data Type

Use the int8 data type to declare host variables for database values of type INT8 and SERIAL8. Figure 5-1 shows the fields of the structure ifx_int8_t, which represents an INT8 or SERIAL8 value.

Figure 5-1
Fields of the ifx_int8_t Structure

Field Name Field Type Purpose

data

unsigned
long
[INT8SIZE]

An array of integer values that make up the 8-byte integer value. When the INT8SIZE constant is defined as 2, this array contains two 4-byte unsigned integers. The actual data type of an unsigned 4-byte integer can be machine specific.

sign

short integer

A short integer to hold the sign (NULL, negative, or positive) of the 8-byte integer. The actual data type of a 2-byte integer can be machine specific.

The int8.h header file contains the ifx_int8 structure and a typedef called ifx_int8_t. Include this file in all C source files that use any int8 host variables as shown in the following example:

You can declare an int8 host variable in either of the following ways:

Implicit Data Conversion for int8 Values

All operations on int8 type numbers take place through the functions that the ESQL/C library provides. Any other operations, modifications, or analyses can produce unpredictable results. ESQL/C provides functions that facilitate conversion of int8 data type numbers to and from each C-language data type. The following section describes these functions.

Operations on int8 Values

The ESQL/C int8 data type uses its own internal structure to store large integer values. (For more information, see "The int8 Data Type".) Use the following ESQL/C library functions to perform all operations on int8 type numbers.

ifx_int8add()

ifx_int8copy()

ifx_int8mul

ifx_int8cmp()

ifx_int8div()

ifx_int8sub()

Any other operations, modifications, or comparisons can produce unpredictable results. For more information on how to use these functions, refer to "The int8 Library Functions".

Data Conversion for int8 Values

ESQL/C provides the following library functions to support conversion of int8 values to and from other data types.

ifx_int8cvasc()

ifx_int8cvint()

ifx_int8todec()

ifx_int8cvdbl()

ifx_int8cvlong()

ifx_int8toflt()

ifx_int8cvdec()

ifx_int8toasc()

ifx_int8toint()

ifx_int8cvflt()

ifx_int8todbl()

ifx_int8tolong()

For more information on how to use these functions, refer to "The int8 Library Functions".




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