1 #include <stdio.h>
2 #include <sys/types.h>
3 #include "dfp_utils.h"
4
5 volatile _Decimal32 d32_1, d32_2;
6 volatile _Decimal64 d64_1, d64_2;
7 volatile _Decimal128 d128_1, d128_2;
8
main(void)9 int main(void)
10 {
11 d64_1 = 5.000005DD;
12 d64_2 = 60000.4DD;
13 d32_1 = 3.000002DF;
14 d32_2 = 500000.000005DF;
15 d128_1 = 100000000.000028DL;
16
17 d64_1 = (_Decimal64) d32_1; //Exercise LDETR (load lengthened)
18 printf("D32 -> D64 : ");
19 DFP_VAL_PRINT(d32_1, _Decimal32);
20 printf(" -> ");
21 DFP_VAL_PRINT(d64_1, _Decimal64);
22
23 d128_2 = (_Decimal128) d64_2; //Exercise LXDTR (load lengthened)
24 printf("\nD64 -> D128 : ");
25 DFP_VAL_PRINT(d64_2, _Decimal64);
26 printf(" -> ");
27 DFP_VAL_PRINT(d128_2, _Decimal128);
28
29 d32_2 = (_Decimal32) d64_2; //Exercise LEDTR (load rounded)
30 printf("\nD64 -> D32 : ");
31 DFP_VAL_PRINT(d64_2, _Decimal64);
32 printf(" -> ");
33 DFP_VAL_PRINT(d32_2, _Decimal32);
34
35 d64_2 = (_Decimal64) d128_1; //Exercise LDXTR (load rounded)
36 printf("\nD128 -> D64 : ");
37 DFP_VAL_PRINT(d128_1, _Decimal128);
38 printf(" -> ");
39 DFP_VAL_PRINT(d64_2, _Decimal64);
40 printf("\n");
41
42 return 0;
43 }
44