1 /* C99 6.5.3 Unary operators. */ 2 3 #include "dfp-dbg.h" 4 5 #define AUTO_INCREASE_DECREASE(TYPE,SUFFIX) \ 6 do \ 7 { \ 8 _Decimal##TYPE in_de_d##TYPE = 0.0##SUFFIX; \ 9 if (in_de_d##TYPE++) FAILURE \ 10 if (--in_de_d##TYPE) FAILURE \ 11 if (++in_de_d##TYPE == 0.0##SUFFIX) FAILURE \ 12 if (in_de_d##TYPE-- == 0.0##SUFFIX) FAILURE \ 13 } while(0) 14 15 #define UNARY_OPERATOR(TYPE,SUFFIX) \ 16 do \ 17 { \ 18 _Decimal##TYPE unary_d##TYPE = 1.0##SUFFIX; \ 19 _Decimal##TYPE* unary_dp##TYPE; \ 20 /* & operator. */ \ 21 unary_dp##TYPE = &(unary_d##TYPE); \ 22 /* * operator. */ \ 23 unary_d##TYPE = *(unary_dp##TYPE); \ 24 /* - operator. */ \ 25 unary_d##TYPE = -unary_d##TYPE; \ 26 if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ 27 /* + operator. */ \ 28 unary_d##TYPE = +unary_d##TYPE; \ 29 if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ 30 if (!unary_d##TYPE) FAILURE /*! operator. */ \ 31 } while (0) 32 33 int main()34main () 35 { 36 /* C99 6.5.3.1 Prefix increment and decrement operators. */ 37 AUTO_INCREASE_DECREASE(32, DF); 38 AUTO_INCREASE_DECREASE(64, DD); 39 AUTO_INCREASE_DECREASE(128, DL); 40 41 /* C99 6.5.3 Unary operators. */ 42 UNARY_OPERATOR(32, DF); 43 UNARY_OPERATOR(64, DD); 44 UNARY_OPERATOR(128, DL); 45 46 /* C99 6.5.3 Unary operators for zero values. */ 47 if (- +0.df != -0.df) FAILURE 48 if (+ -0.df != -0.df) FAILURE 49 if (- -0.df != +0.df) FAILURE 50 51 FINISH 52 } 53