Home | Previous Page | Next Page   Data Manipulation > Using Numeric Data Types > Floating-Point Data >

Floating-Point Binary Representations

The DataBlade API provides the following data types to support the binary representations of floating-point values.

SQL Floating-Point Data Type DataBlade API Data Type
DECIMAL mi_decimal
SMALLFLOAT mi_real
FLOAT mi_double_precision

DECIMAL Data Type: Floating-Point Data

When you define a column with the DECIMAL(p) data type, the syntax of this definition specifies a floating-point value for the column. This value has a total of p (<= 32) significant digits (its precision). DECIMAL(p) has an absolute value range between 10-130 and 10124.

Tip:
The DECIMAL data type can also declare a fixed-point value with the syntax DECIMAL(p,s). For more information, see DECIMAL Data Type: Fixed-Point Data. For a complete description of the DECIMAL data type, see the IBM Informix: Guide to SQL Reference.

The mi_decimal data type stores floating-point DECIMAL values as well as fixed-point values. Therefore, information about mi_decimal in Fixed-Point Data also applies to mi_decimal when it contains a floating-point value. In particular, the following statements are true.

Decimal Information More Information
The mi_decimal data type stores values in an internal (binary) format. Internal Fixed-Point Decimal Format
All the ESQL/C library functions that handle fixed-point values in mi_decimal can also handle mi_decimal when it contains floating-point values. ESQL/C DECIMAL-Type Functions
All DataBlade API functions that accept fixed-point values in mi_decimal also accept mi_decimal when it contains a floating-point value. Transferring Fixed-Point Data (Server) and Converting Decimal Data
Server Only

Values of the mi_decimal data type cannot fit into an MI_DATUM structure. They must be passed by reference within C UDRs.

End of Server Only
Client Only

All data types, including mi_decimal, must be passed by reference within client LIBMI applications.

End of Client Only

SMALLFLOAT Data Type

The SQL SMALLFLOAT data type can hold single-precision floating-point values. The DataBlade API supports the SMALLFLOAT data type with the mi_real data type. The mi_real data type stores internal SMALLFLOAT values, as 32-bit floating-point values.

Server Only

Although an mi_real value can fit into an MI_DATUM structure, values of this data type are always passed by reference. Unlike other four-byte values, mi_real values cannot be passed by value. All values greater than four bytes are passed by reference.

Therefore, if a UDR is called from an SQL statement, the database server passed a pointer to any mi_real arguments; it does not pass the actual value. Similarly, if a user-defined function returns an mi_real value to an SQL statement, you must allocate space for the value, fill this space, and return a pointer to this space.

DataBlade API modules that are not invoked from SQL statements might pass mi_real values by value. However, for consistency, you might want to pass them by reference.

End of Server Only
Client Only

All data types, including mi_real, must be passed by reference within client LIBMI applications.

End of Client Only
Important:
To make your DataBlade API module portable across different architectures, it is recommended that you use the DataBlade API data type, mi_real, instead of the native C-language counterpart, float. The mi_real data type handles the different sizes of small floating-point values across computer architectures.

The FLOAT Data Type

The SQL FLOAT data type can hold double-precision floating-point values. The DataBlade API supports the FLOAT data type with the mi_double_precision data type. The mi_double_precision data type stores internal FLOAT values, as 64-bit floating-point values.

Server Only

Values of the mi_double_precision data type cannot fit into an MI_DATUM structure. They must be passed by reference within C UDRs.

End of Server Only
Client Only

All data types, including mi_double_precision, must be passed by reference within client LIBMI applications.

End of Client Only
Important:
To make your DataBlade API module portable across different architectures, it is recommended that you use the DataBlade API data type, mi_double_precision, instead of the native C-language counterpart, double. The mi_double_precision data type handles the different sizes of large floating-point values across computer architectures.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]