------------------------------------------------------------------ */ decFloatNextPlus -- next towards +Infinity */ / result gets the next larger decFloat */ dfl is the decFloat to start with */ set is the context */ returns result
| 2733 | /* an sNaN). */ |
| 2734 | /* ------------------------------------------------------------------ */ |
| 2735 | decFloat * decFloatNextPlus(decFloat *result, const decFloat *dfl, |
| 2736 | decContext *set) { |
| 2737 | uInt savestat; // saves status |
| 2738 | enum rounding saveround; // .. and mode |
| 2739 | decFloat delta; // tiny increment |
| 2740 | |
| 2741 | // -Infinity is the special case |
| 2742 | if (DFISINF(dfl) && DFISSIGNED(dfl)) { |
| 2743 | DFSETNMAX(result); |
| 2744 | DFWORD(result, 0)|=DECFLOAT_Sign; // make negative |
| 2745 | return result; // [no status to set] |
| 2746 | } |
| 2747 | // other cases are effected by sutracting a tiny delta -- this |
| 2748 | // should be done in a wider format as the delta is unrepresentable |
| 2749 | // here (but can be done with normal add if the sign of zero is |
| 2750 | // treated carefully, because no Inexactitude is interesting); |
| 2751 | // rounding to +Infinity then pushes the result to next above |
| 2752 | decFloatZero(&delta); // set up tiny delta |
| 2753 | DFWORD(&delta, DECWORDS-1)=1; // coefficient=1 |
| 2754 | DFWORD(&delta, 0)=0; // Sign=0 + biased exponent=0 |
| 2755 | // set up for the directional round |
| 2756 | saveround=set->round; // save mode |
| 2757 | set->round=DEC_ROUND_CEILING; // .. round towards +Infinity |
| 2758 | savestat=set->status; // save status |
| 2759 | decFloatAdd(result, dfl, &delta, set); |
| 2760 | // Add rules mess up the sign when going from -Ntiny to -0 |
| 2761 | if (DFISZERO(result)) DFWORD(result, 0)^=DECFLOAT_Sign; // correct |
| 2762 | set->status&=DEC_Invalid_operation; // preserve only sNaN status |
| 2763 | set->status|=savestat; // restore pending flags |
| 2764 | set->round=saveround; // .. and mode |
| 2765 | return result; |
| 2766 | } // decFloatNextPlus |
| 2767 | |
| 2768 | /* ------------------------------------------------------------------ */ |
| 2769 | /* decFloatNextToward -- next towards a decFloat */ |
nothing calls this directly
no test coverage detected