CMPtype DFP_GE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) { int stat; stat = dfp_compare_op (decNumberCompare, arg_a, arg_b); /* For GE return 1 (>=0) for true, -1 for false. */ return (stat != -1) ? 1 : -1; }
CMPtype DFP_LE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) { int stat; stat = dfp_compare_op (decNumberCompare, arg_a, arg_b); /* For LE return 0 (<= 0) for true, 1 for false. */ return stat == 1; }
CMPtype DFP_LT (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) { int stat; stat = dfp_compare_op (decNumberCompare, arg_a, arg_b); /* For LT return -1 (<0) for true, 1 for false. */ return (stat == -1) ? -1 : 1; }
CMPtype DFP_NE (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) { int stat; stat = dfp_compare_op (decNumberCompare, arg_a, arg_b); /* For NE return nonzero for true, zero for false. */ return stat != 0; }
/* decFloat comparisons are supported for decDouble (64 bits) and decQuad (128 bits). The bit patterns for the types are the same. */ static inline CMPtype dnn_compare_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) { union { DFP_C_TYPE c; decFloat f; } a, b; a.c = arg_a; b.c = arg_b; return dfp_compare_op (op, a.f, b.f); }
/* The decNumber package doesn't provide comparisons for decSingle (32 bits); convert to decDouble, use the operation for that, and convert back. */ static inline CMPtype d32_compare_op (dfp_binary_func op, _Decimal32 arg_a, _Decimal32 arg_b) { union { _Decimal32 c; decSingle f; } a32, b32; decDouble a, b; a32.c = arg_a; b32.c = arg_b; decSingleToWider (&a32.f, &a); decSingleToWider (&b32.f, &b); return dfp_compare_op (op, a, b); }