The following program converts two double type numbers to INT8 types and displays the results. */
#include
EXEC SQL include "int8.h";
char result[41];
main() { mint x; ifx_int8_t num; double d = 2147483647;
printf("IFX_INT8CVDBL Sample ESQL Program running.\n\n");
printf("Number 1 (double) = 1234.5678901234\n"); if (x = ifx_int8cvdbl((double)1234.5678901234, #)) { printf("Error %d in converting double1 to INT8\n", x); exit(1); } if (x = ifx_int8toasc(#, result, sizeof(result))) { printf("Error %d in converting INT8 to string\n", x); exit(1); } result[40] = '\0'; printf(" String Value = %s\n", result); /* notice that the ifx_int8cvdbl function truncates digits to the right of a decimal separator. */
GBase 8s ESQL/C 编程指南 南大通用数据技术股份有限公司 - 727 -
printf("Number 2 (double) = %.1f\n", d); if (x = ifx_int8cvdbl(d, #)) { printf("Error %d in converting double2 to INT8\n", x); exit(1); } if (x = ifx_int8toasc(#, result, sizeof(result))) { printf("Error %d in converting second INT8 to string\n", x); exit(1); } result[40] = '\0'; printf(" String Value = %s\n", result);
printf("\nIFX_INT8CVDBL Sample Program over.\n\n"); exit(0); } 输出
IFX_INT8CVDBL Sample ESQL Program running.
Number 1 (double) = 1234.5678901234 String Value = 1234 Number 2 (double) = 2147483647.0 String Value = 2147483647 IFX_INT8CVDBL Sample Program over.\