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

Converting Decimal Data

Both the DataBlade API library and the ESQL/C library provide functions that convert the binary representation for DECIMAL (mi_decimal) or MONEY (mi_money) values.

DataBlade API Functions for Decimal Conversion

The DataBlade API library provides the following functions that convert between a text (string) representation of a decimal or monetary value and its binary (internal) equivalent.

DataBlade API Function Converts from Converts to
mi_decimal_to_string( ) DECIMAL (mi_decimal) Decimal string
mi_money_to_string( ) MONEY (mi_money) Interval string
mi_string_to_decimal( ) Decimal string DECIMAL (mi_decimal)
mi_string_to_money( ) Monetary string MONEY (mi_money)
Server Only

The mi_decimal_to_string( ), mi_money_to_string( ), mi_string_to_decimal( ), and mi_string_to_money( ) functions are useful in the input and output support function of an opaque data type that contains mi_decimal or mi_money values. They allow you to convert fixed-point (DECIMAL or MONEY) values between their external format (text) and their internal format (dec_t) when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data Between Text and Binary Representations.

End of Server Only
Global Language Support

The mi_decimal_to_string( ), mi_money_to_string( ), mi_string_to_decimal( ), and mi_string_to_money( ) functions use the current processing locale to handle locale-specific formats in the decimal or monetary string. For more information, see the IBM Informix: GLS User's Guide.

End of Global Language Support

ESQL/C Functions for Decimal Conversion

The ESQL/C function library provides the following functions to convert a DECIMAL (or MONEY) value to and from some C-language data types.

Function Name
Description
deccvasc( )
Converts a C char type to an mi_decimal type value
deccvdbl( )
Converts a C double (mi_double_precision) type to an mi_decimal type value
deccvint( )
Converts a C two-byte integer value to an mi_decimal type value
deccvlong( )
Converts a C four-byte integer value to an mi_decimal type value
dececvt( ) and decfcvt( )
Converts an mi_decimal type value to text
dectoasc( )
Converts an mi_decimal type value to text
dectodbl( )
Converts an mi_decimal type value to a C double (mi_double_precision) type value
dectoint( )
Converts an mi_decimal type value to a C two-byte integer value
dectolong( )
Converts an mi_decimal type value to a C four-byte integer value
Tip:
The ESQL/C library also provides functions to convert some numeric data types to formatted strings. For more information, see Formatting Numeric Strings.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]