The database fixed-point number high level API module has the file name dbfxp.c. This module provides the programmer with a high level callable API that will store or retrieve database fields, subfields or subsubfields containing fixed-point numbers.
The fixed-point numbers are stored in database fields, subfields or subsubfields without the decimal point. The application designer must decide and keep track of where the decimal is placed. This is referred to in this document as the scale.
This API is available for all platforms. Each function requires a tid as the first function parameter.
Here is a list of functions in this module:
This module requires the following modules:
In the Linux/Unix/QNX platforms, this module is compiled along with the other database modules as part of the script cdbeng.
This module depends on the following header files:
Prototype : int dbfxp_get(int tid, int field_no, int sc, struct fxp **r1) Parameters : Name : tid Description : tid Name : field_no Description : field number Name : sc Description : precision or scale of number Name : r1 Description : returned fixed-point number Returns : dbeng code
This function will obtain the field contents from the tid table, in the field number field. The field contents will be used to create a fixed-point number with the decimal located in the precision or scale of number position (from the right). Function returns a dynamically allocated fxp structure upon success. The fxp structure must be de-allocated by the caller. The field contents must be a number (0-9,-) without any decimal point.
Prototype : int dbfxp_put(int tid, int field_no, int sc, struct fxp *r1) Parameters : Name : tid Description : tid Name : field_no Description : field number Name : sc Description : precision or scale of number Name : r1 Description : fixed-point number Returns : dbeng code
This function will write a fixed-point number to a database field. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the field contents.
Prototype : int dbfxp_get_subfield(int tid, int f, int sf, int sc, struct fxp **r1) Parameters : Name : tid Description : tid Name : f Description : field number Name : sf Description : subfield number Name : sc Description : precision or scale of number Name : r1 Description : returned fixed-point number Returns : dbeng code
This function will obtain subfield contents from the tid table in the field number and subfield number. The subfield contents will be used to create a fixed-point number (fxp) with the decimal located in the precision or scale of number position (from the right). Function returns a dynamically allocated fxp structure upon success. The fxp structure must be de-allocated by the caller. The subfield contents must be a number (0-9,-) without any decimal point.
Prototype : int dbfxp_put_subfield(int tid, int f, int sf, int sc, struct fxp *r1) Parameters : Name : tid Description : tid Name : f Description : field number Name : sf Description : subfield number Name : sc Description : precision or scale of number Name : r1 Description : fixed-point number Returns : dbeng code
This function will write a fixed-point number to a database subfield. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the subfield contents.
Prototype : int dbfxp_get_subsubfield(int tid, int f, int sf, int ssf, int sc, struct fxp **r1) Parameters : Name : tid Description : tid Name : f Description : field number Name : sf Description : subfield number Name : ssf Description : subsubfield number Name : sc Description : precision or scale of number Name : r1 Description : returned fixed-point number Returns : dbeng code
This function will obtain subsubfield contents from the tid table in the field number, subfield number and subsubfield number. The subsubfield contents will be used to create a fixed-point number (fxp) with the decimal located in the precision or scale of number position (from the right). Function returns a dynamically allocated fxp structure upon success. The fxp structure must be de-allocated by the caller. The subsubfield contents must be a number (0-9,-) without any decimal point.
Prototype : int dbfxp_put_subsubfield(int tid, int f, int sf, int ssf, int sc, struct fxp *r1) Parameters : Name : tid Description : tid Name : f Description : field number Name : sf Description : subfield number Name : ssf Description : subsubfield number Name : sc Description : precision or scale of number Name : r1 Description : fixed-point number Returns : dbeng code
This function will write a fixed-point number to a database subsubfield. The number will be written without a decimal point (if any). The number will have its scale adjusted (position of the decimal point) to the precision or scale of number. The caller must know the number scale. A database write will not take place after writing the subsubfield contents.