11106692158e71bade4e00a2d21548e74b2ea334eflorian#include <stdio.h>
21106692158e71bade4e00a2d21548e74b2ea334eflorian#include <stdint.h>
31106692158e71bade4e00a2d21548e74b2ea334eflorian#include "dfp_utils.h"
41106692158e71bade4e00a2d21548e74b2ea334eflorian#define __STDC_WANT_DEC_FP__ 1
51106692158e71bade4e00a2d21548e74b2ea334eflorian#include <float.h>
61106692158e71bade4e00a2d21548e74b2ea334eflorian
71106692158e71bade4e00a2d21548e74b2ea334eflorian#ifndef PFPO_FUNCTIONS
81106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_FUNCTIONS
94027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_F32_TO_D32   0x01080500
104027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D32_TO_F32   0x01050800
114027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_F32_TO_D64   0x01090500
124027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D32_TO_F64   0x01060800
134027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_F32_TO_D128  0x010A0500
144027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D32_TO_F128  0x01070800
154027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_F64_TO_D32   0x01080600
164027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D64_TO_F32   0x01050900
171106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_F64_TO_D64   0x01090600
181106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_D64_TO_F64   0x01060900
191106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_F64_TO_D128  0x010A0600
204027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D64_TO_F128  0x01070900
214027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D128_TO_F64  0x01060A00
224027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_F128_TO_D32  0x01080700
234027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_D128_TO_F32  0x01050A00
244027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO_F128_TO_D64  0x01090700
251106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_D128_TO_F64  0x01060A00
261106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_F128_TO_D128 0x010A0700
271106692158e71bade4e00a2d21548e74b2ea334eflorian#define PFPO_D128_TO_F128 0x01070A00
281106692158e71bade4e00a2d21548e74b2ea334eflorian
294027d32ca555d7647e8c2e2c76ecc996224e96deflorian#define PFPO(initial, src_type, dst_type, fn_code, round, ret_code, cc) \
304027d32ca555d7647e8c2e2c76ecc996224e96deflorian({                                                                      \
314027d32ca555d7647e8c2e2c76ecc996224e96deflorian  register src_type src_reg asm("f4") = initial;                        \
324027d32ca555d7647e8c2e2c76ecc996224e96deflorian  register dst_type dst_reg asm("f0");                                  \
334027d32ca555d7647e8c2e2c76ecc996224e96deflorian  register unsigned long fn asm("0") = fn_code | (round & 0xf);         \
344027d32ca555d7647e8c2e2c76ecc996224e96deflorian  register unsigned int ret asm("1");                                   \
354027d32ca555d7647e8c2e2c76ecc996224e96deflorian  asm volatile(".short 0x010a\n\t"                                      \
364027d32ca555d7647e8c2e2c76ecc996224e96deflorian               "ipm %2\n\t"                                             \
374027d32ca555d7647e8c2e2c76ecc996224e96deflorian               "srl %2,28\n\t"                                          \
384027d32ca555d7647e8c2e2c76ecc996224e96deflorian               :"=f"(dst_reg), "=d"(ret), "=d" (cc)                     \
394027d32ca555d7647e8c2e2c76ecc996224e96deflorian               : "f"(src_reg), "d"(fn));                                \
404027d32ca555d7647e8c2e2c76ecc996224e96deflorian  ret_code = ret;                                                       \
414027d32ca555d7647e8c2e2c76ecc996224e96deflorian  dst_reg;                                                              \
424027d32ca555d7647e8c2e2c76ecc996224e96deflorian})
431106692158e71bade4e00a2d21548e74b2ea334eflorian
444027d32ca555d7647e8c2e2c76ecc996224e96deflorian#endif /* PFPO_FUNCTIONS */
451106692158e71bade4e00a2d21548e74b2ea334eflorian
464027d32ca555d7647e8c2e2c76ecc996224e96deflorian/* Test BFP <-> DFP conversions */
474027d32ca555d7647e8c2e2c76ecc996224e96deflorianint main()
481106692158e71bade4e00a2d21548e74b2ea334eflorian{
491106692158e71bade4e00a2d21548e74b2ea334eflorian  int cc;
504027d32ca555d7647e8c2e2c76ecc996224e96deflorian  uint8_t i, j;
511106692158e71bade4e00a2d21548e74b2ea334eflorian  unsigned int ret_code;
521106692158e71bade4e00a2d21548e74b2ea334eflorian
534027d32ca555d7647e8c2e2c76ecc996224e96deflorian  float f32;
544027d32ca555d7647e8c2e2c76ecc996224e96deflorian  double f64;
554027d32ca555d7647e8c2e2c76ecc996224e96deflorian  long double f128;
561106692158e71bade4e00a2d21548e74b2ea334eflorian
574027d32ca555d7647e8c2e2c76ecc996224e96deflorian  _Decimal32 d32;
584027d32ca555d7647e8c2e2c76ecc996224e96deflorian  _Decimal64 d64;
594027d32ca555d7647e8c2e2c76ecc996224e96deflorian  _Decimal128 d128;
601106692158e71bade4e00a2d21548e74b2ea334eflorian
614027d32ca555d7647e8c2e2c76ecc996224e96deflorian  float f32_in[] = {123.5656789, FLT_MAX, FLT_MIN};
624027d32ca555d7647e8c2e2c76ecc996224e96deflorian  double f64_in[] = {123456789999.5656789, DBL_MIN, DBL_MAX};
634027d32ca555d7647e8c2e2c76ecc996224e96deflorian  long double f128_in[] = {1234567812345678912345678912.5656789L,
644027d32ca555d7647e8c2e2c76ecc996224e96deflorian                           LDBL_MIN, LDBL_MAX};
651106692158e71bade4e00a2d21548e74b2ea334eflorian
664027d32ca555d7647e8c2e2c76ecc996224e96deflorian  _Decimal32 d32_in[] = {123.5656789DF, DEC32_MAX, DEC32_MIN};
674027d32ca555d7647e8c2e2c76ecc996224e96deflorian  _Decimal64 d64_in[] = {123456789999.5656789DD, DEC64_MIN, DEC64_MAX};
684027d32ca555d7647e8c2e2c76ecc996224e96deflorian  _Decimal128 d128_in[] = {1234567812345678912345678912.5656789DL,
694027d32ca555d7647e8c2e2c76ecc996224e96deflorian                           DEC128_MIN, DEC128_MAX};
701106692158e71bade4e00a2d21548e74b2ea334eflorian
714027d32ca555d7647e8c2e2c76ecc996224e96deflorian /* valid function code */
724027d32ca555d7647e8c2e2c76ecc996224e96deflorian  PFPO(0., double, _Decimal64, 0x81090600, 0, ret_code, cc);
734027d32ca555d7647e8c2e2c76ecc996224e96deflorian  printf("pfpo test: function=%x ret=%d cc=%d\n", 0x81090600, ret_code, cc);
741106692158e71bade4e00a2d21548e74b2ea334eflorian
754027d32ca555d7647e8c2e2c76ecc996224e96deflorian /* invalid function code */
764027d32ca555d7647e8c2e2c76ecc996224e96deflorian  PFPO(0., double, _Decimal64, 0x81990600, 0, ret_code, cc);
774027d32ca555d7647e8c2e2c76ecc996224e96deflorian  printf("pfpo test: function=%x ret=%d cc=%d\n", 0x81990600, ret_code, cc);
781106692158e71bade4e00a2d21548e74b2ea334eflorian
791106692158e71bade4e00a2d21548e74b2ea334eflorian  for (i = 0; i < 16; i++) {
801106692158e71bade4e00a2d21548e74b2ea334eflorian    if (i < 2 || i > 7) {
814027d32ca555d7647e8c2e2c76ecc996224e96deflorian
824027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f32 -> d32 */
834027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
844027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f32 -> d32: round=%x ", i);
854027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%f -> ", f32_in[j]);
864027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d32 = PFPO(f32_in[j], float, _Decimal32, PFPO_F32_TO_D32,
874027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
884027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d32, _Decimal32);
894027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
904027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
914027d32ca555d7647e8c2e2c76ecc996224e96deflorian
924027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f32 -> d64 */
934027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
944027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f32 -> d64: round=%x ", i);
954027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%f -> ", f32_in[j]);
964027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d64 = PFPO(f32_in[j], float, _Decimal64, PFPO_F32_TO_D64,
974027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
984027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d64, _Decimal64);
994027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1004027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1014027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1024027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f32 -> d128 */
1034027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1044027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f32 -> d128: round=%x ", i);
1054027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%f -> ", f32_in[j]);
1064027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d128 = PFPO(f32_in[j], float, _Decimal128, PFPO_F32_TO_D128,
1074027d32ca555d7647e8c2e2c76ecc996224e96deflorian                    i, ret_code, cc);
1084027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d128, _Decimal128);
1094027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1104027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1114027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1124027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f64 -> d32 */
1134027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1144027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f64 -> d32: round=%x ", i);
1154027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%lf -> ", f64_in[j]);
1164027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d32 = PFPO(f64_in[j], double, _Decimal32, PFPO_F64_TO_D32,
1174027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1184027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d32, _Decimal32);
1194027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1204027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1214027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1224027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f64 -> d64 */
1234027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1244027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f64 -> d64: round=%x ", i);
1254027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%lf -> ", f64_in[j]);
1264027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d64 = PFPO(f64_in[j], double, _Decimal64, PFPO_F64_TO_D64,
1274027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1284027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d64, _Decimal64);
1294027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1304027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1314027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1324027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f64 -> d128 */
1334027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1344027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f64 -> d128: round=%x ", i);
1354027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%lf -> ", f64_in[j]);
1364027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d128 = PFPO(f64_in[j], double, _Decimal128, PFPO_F64_TO_D128,
1374027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1384027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d128, _Decimal128);
1394027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1404027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1414027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1424027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f128 -> d32 */
1434027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1444027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f128 -> d32: round=%x ", i);
1454027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%Lf -> ", f128_in[j]);
1464027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d32 = PFPO(f128_in[j], long double, _Decimal32, PFPO_F128_TO_D32,
1474027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1484027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d32, _Decimal32);
1494027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1504027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1514027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1524027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f128 -> d64 */
1534027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1544027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f128 -> d6: round=%x ", i);
1554027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%Lf -> ", f128_in[j]);
1564027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d64 = PFPO(f128_in[j], long double, _Decimal64, PFPO_F128_TO_D64,
1574027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1584027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d64, _Decimal64);
1594027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1604027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1614027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1624027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* f128 -> d128 */
1634027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1644027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("f128 -> d128: round=%x ", i);
1654027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%Lf -> ", f128_in[j]);
1664027d32ca555d7647e8c2e2c76ecc996224e96deflorian        d128 = PFPO(f128_in[j], long double, _Decimal128, PFPO_F128_TO_D128,
1674027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1684027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d128, _Decimal128);
1694027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1704027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1714027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1724027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d32 -> f32 */
1734027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1744027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d32 -> f32: round=%x ", i);
1754027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d32_in[j], _Decimal32);
1764027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
1774027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f32 = PFPO(d32_in[j], _Decimal32, float, PFPO_D32_TO_F32,
1784027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1794027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%f", f32);
1804027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1814027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1824027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1834027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d32 -> f64 */
1844027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1854027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d32 -> f64: round=%x ", i);
1864027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d32_in[j], _Decimal32);
1874027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
1884027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f64 = PFPO(d32_in[j], _Decimal32, double, PFPO_D32_TO_F64,
1894027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
1904027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%lf", f64);
1914027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
1924027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
1934027d32ca555d7647e8c2e2c76ecc996224e96deflorian
1944027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d32 -> f128 */
1954027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
1964027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d32 -> f128: round=%x ", i);
1974027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d32_in[j], _Decimal32);
1984027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
1994027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f128 = PFPO(d32_in[j], _Decimal32, long double, PFPO_D32_TO_F128,
2004027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2014027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%Lf", f128);
2024027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2034027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2044027d32ca555d7647e8c2e2c76ecc996224e96deflorian
2054027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d64 -> f32 */
2064027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
2074027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d64 -> f32: round=%x ", i);
2084027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d64_in[j], _Decimal64);
2094027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
2104027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f32 = PFPO(d64_in[j], _Decimal64, float, PFPO_D64_TO_F32,
2114027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2124027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%f", f32);
2134027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2144027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2154027d32ca555d7647e8c2e2c76ecc996224e96deflorian
2164027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d64 -> f64 */
2174027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
2184027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d64 -> f64: round=%x ", i);
2194027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d64_in[j], _Decimal64);
2204027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
2214027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f64 = PFPO(d64_in[j], _Decimal64, double, PFPO_D64_TO_F64,
2224027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2234027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%lf", f64);
2244027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2254027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2264027d32ca555d7647e8c2e2c76ecc996224e96deflorian
2274027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d64 -> f128 */
2284027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
2294027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d64 -> f128: round=%x ", i);
2304027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d64_in[j], _Decimal64);
2314027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
2324027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f128 = PFPO(d64_in[j], _Decimal64, long double, PFPO_D64_TO_F128,
2334027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2344027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%Lf", f128);
2354027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2364027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2374027d32ca555d7647e8c2e2c76ecc996224e96deflorian
2384027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d128 -> f32 */
2394027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
2404027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d128 -> f32: round=%x ", i);
2414027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d128_in[j], _Decimal128);
2424027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
2434027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f32 = PFPO(d128_in[j], _Decimal128, float, PFPO_D128_TO_F32,
2444027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2454027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%f", f32);
2464027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2474027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2484027d32ca555d7647e8c2e2c76ecc996224e96deflorian
2494027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d128 -> f64 */
2504027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
2514027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d128 -> f64: round=%x ", i);
2524027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d128_in[j], _Decimal128);
2534027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
2544027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f64 = PFPO(d128_in[j], _Decimal128, double, PFPO_D128_TO_F64,
2554027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2564027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%lf", f64);
2574027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2584027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2594027d32ca555d7647e8c2e2c76ecc996224e96deflorian
2604027d32ca555d7647e8c2e2c76ecc996224e96deflorian      /* d128 -> f128 */
2614027d32ca555d7647e8c2e2c76ecc996224e96deflorian      for(j = 0; j < 3; j++) {
2624027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("d128 -> f128: round=%x ", i);
2634027d32ca555d7647e8c2e2c76ecc996224e96deflorian        DFP_VAL_PRINT(d128_in[j], _Decimal128);
2644027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" -> ");
2654027d32ca555d7647e8c2e2c76ecc996224e96deflorian        f128 = PFPO(d128_in[j], _Decimal128, long double, PFPO_D128_TO_F128,
2664027d32ca555d7647e8c2e2c76ecc996224e96deflorian                   i, ret_code, cc);
2674027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf("%Lf", f128);
2684027d32ca555d7647e8c2e2c76ecc996224e96deflorian        printf(" ret=%d cc=%d\n", ret_code, cc);
2694027d32ca555d7647e8c2e2c76ecc996224e96deflorian      }
2701106692158e71bade4e00a2d21548e74b2ea334eflorian    }
2711106692158e71bade4e00a2d21548e74b2ea334eflorian  }
2721106692158e71bade4e00a2d21548e74b2ea334eflorian  return 0;
2731106692158e71bade4e00a2d21548e74b2ea334eflorian}
274