- if (EXPISSPECIAL(expl | expr)) { /* either is special? */
- if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set);
- /* one or two infinities */
- /* two infinities with different signs is invalid */
- if (diffsign && DFISINF(dfl) && DFISINF(dfr))
- return decInvalid(result, set);
- if (DFISINF(dfl)) return decInfinity(result, dfl); /* LHS is infinite */
- return decInfinity(result, dfr); /* RHS must be Infinite */
- }
+ /* now determine whether to take a fast path or the full-function */
+ /* slow path. The slow path must be taken when: */
+ /* -- both numbers are finite, and: */
+ /* the exponents are different, or */
+ /* the signs are different, or */
+ /* the sum of the MSDs is >8 (hence might overflow) */
+ /* specialness and the sum of the MSDs can be tested at once using */
+ /* the summ value just calculated, so the test for specials is no */
+ /* longer on the worst-case path (as of 3.60) */
+
+ if (summ<=8) { /* MSD+MSD is good, or there is a special */
+ if (summ<0) { /* there is a special */
+ /* Inf+Inf would give -64; Inf+finite is -32 or higher */
+ if (summ<-64) return decNaNs(result, dfl, dfr, set); /* one or two NaNs */
+ /* two infinities with different signs is invalid */
+ if (summ==-64 && diffsign) return decInvalid(result, set);
+ if (DFISINF(dfl)) return decInfinity(result, dfl); /* LHS is infinite */
+ return decInfinity(result, dfr); /* RHS must be Inf */
+ }
+ /* Here when both arguments are finite; fast path is possible */
+ /* (currently only for aligned and same-sign) */
+ if (bexpr==bexpl && !diffsign) {
+ uInt tac[DECLETS+1]; /* base-1000 coefficient */
+ uInt encode; /* work */
+
+ /* Get one coefficient as base-1000 and add the other */
+ GETCOEFFTHOU(dfl, tac); /* least-significant goes to [0] */
+ ADDCOEFFTHOU(dfr, tac);
+ /* here the sum of the MSDs (plus any carry) will be <10 due to */
+ /* the fastpath test earlier */
+
+ /* construct the result; low word is the same for both formats */
+ encode =BIN2DPD[tac[0]];
+ encode|=BIN2DPD[tac[1]]<<10;
+ encode|=BIN2DPD[tac[2]]<<20;
+ encode|=BIN2DPD[tac[3]]<<30;
+ DFWORD(result, (DECBYTES/4)-1)=encode;
+
+ /* collect next two declets (all that remains, for Double) */
+ encode =BIN2DPD[tac[3]]>>2;
+ encode|=BIN2DPD[tac[4]]<<8;