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 |
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.
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 |
Values of the mi_decimal data type cannot fit into an MI_DATUM structure. They must be passed by reference within C UDRs.
All data types, including mi_decimal, must be passed by reference within client LIBMI applications.
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.
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.
All data types, including mi_real, must be passed by reference within client LIBMI applications.
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.
Values of the mi_double_precision data type cannot fit into an MI_DATUM structure. They must be passed by reference within C UDRs.
All data types, including mi_double_precision, must be passed by reference within client LIBMI applications.