Lines Matching refs:res

42   UINT128 res = *ptrres; // expected to have the correct sign and coefficient
58 sign = res.w[1] & MASK_SIGN;
60 C_hi = res.w[1] & MASK_COEFF;
61 C_lo = res.w[0];
110 } else { // res = +MAXFP = (10^34-1) * 10^emax
118 } else { // res = -MAXFP = -(10^34-1) * 10^emax
125 res.w[1] = sign | exp | C_hi;
126 res.w[0] = C_lo;
127 *ptrres = res;
288 UINT128 res = *ptrres;
372 res.w[1] = p_sign | ((UINT64) (e4 + 6176) << 49);
373 res.w[0] = 0x0;
374 *ptrres = res;
391 res.w[1] = p_sign | ((UINT64) (e4 + 6176) << 49) | R256.w[1];
392 res.w[0] = R256.w[0];
393 // Note: res is correct only if expmin <= e4 <= expmax
442 ind = p34; // the number of decimal digits in the signifcand of res
443 res.w[1] = p_sign | ((UINT64) (e4 + 6176) << 49) | R128.w[1]; // RN
444 res.w[0] = R128.w[0];
445 // Note: res is correct only if expmin <= e4 <= expmax
449 // res and we know its tininess:
450 // res = (-1)^p_sign * significand * 10^e4,
452 // Note: res is correct only if expmin <= e4 <= expmax
456 res.w[1] = p_sign | 0x7800000000000000ull;
457 res.w[0] = 0x0000000000000000ull;
458 *ptrres = res;
460 return; // BID_RETURN (res)
465 x0 = expmin - e4; // x0 >= 1; the number of digits to chop off of res
480 // nothing is left of res when moving the decimal point left x0 digits
482 res.w[1] = p_sign | 0x0000000000000000ull;
483 res.w[0] = 0x0000000000000000ull;
487 // compare the ind-digit value in the significand of res with
489 // less than, equal to, or greater than 1/2 ulp (significand of res)
490 R128.w[1] = res.w[1] & MASK_COEFF;
491 R128.w[0] = res.w[0];
519 // res = +0.0 * 10^expmin
520 res.w[1] = 0x0000000000000000ull;
521 res.w[0] = 0x0000000000000000ull;
523 // res = +1 * 10^expmin
524 res.w[1] = 0x0000000000000000ull;
525 res.w[0] = 0x0000000000000001ull;
527 res.w[1] = p_sign | res.w[1];
533 round64_2_18 (ind, x0, res.w[0], &R64, &incr_exp,
536 res.w[1] = 0x0;
537 res.w[0] = R64;
539 P128.w[1] = res.w[1] & MASK_COEFF;
540 P128.w[0] = res.w[0];
541 round128_19_38 (ind, x0, P128, &res, &incr_exp,
551 P128.w[1] = res.w[1] & MASK_COEFF;
552 P128.w[0] = res.w[0];
553 __mul_64x128_to_128 (res, ten2k64[1], P128);
555 res.w[1] =
556 p_sign | ((UINT64) (e4 + 6176) << 49) | (res.w[1] & MASK_COEFF);
560 // res = res - 1
561 res.w[0]--;
562 if (res.w[0] == 0xffffffffffffffffull)
563 res.w[1]--;
572 // res = res + 1
573 res.w[0]++;
574 if (res.w[0] == 0)
575 res.w[1]++;
607 // res contains the correct result
613 e4, &res, ptrfpsf);
627 *ptrres = res;
656 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
693 // if x = {0, f, inf, NaN}, y = NaN, z = {0, f, inf, NaN} then res = Q (y)
705 res.w[1] = y.w[1] & 0xfc003fffffffffffull; // clear out also G[6]-G[16]
706 res.w[0] = y.w[0];
709 res.w[1] = y.w[1] & 0xfc003fffffffffffull; // clear out G[6]-G[16]
710 res.w[0] = y.w[0];
722 BID_SWAP128 (res);
723 BID_RETURN (res)
725 // if x = {0, f, inf, NaN}, y = {0, f, inf}, z = NaN then res = Q (z)
737 res.w[1] = z.w[1] & 0xfc003fffffffffffull; // clear out also G[6]-G[16]
738 res.w[0] = z.w[0];
741 res.w[1] = z.w[1] & 0xfc003fffffffffffull; // clear out G[6]-G[16]
742 res.w[0] = z.w[0];
753 BID_SWAP128 (res);
754 BID_RETURN (res)
756 // if x = NaN, y = {0, f, inf}, z = {0, f, inf} then res = Q (x)
768 res.w[1] = x.w[1] & 0xfc003fffffffffffull; // clear out also G[6]-G[16]
769 res.w[0] = x.w[0];
772 res.w[1] = x.w[1] & 0xfc003fffffffffffull; // clear out G[6]-G[16]
773 res.w[0] = x.w[0];
779 BID_SWAP128 (res);
780 BID_RETURN (res)
863 res.w[1] = z_sign | MASK_INF;
864 res.w[0] = 0x0;
867 res.w[1] = 0x7c00000000000000ull;
868 res.w[0] = 0x0000000000000000ull;
873 res.w[1] = p_sign | MASK_INF;
874 res.w[0] = 0x0;
879 res.w[1] = z_sign | MASK_INF;
880 res.w[0] = 0x0;
883 res.w[1] = 0x7c00000000000000ull;
884 res.w[0] = 0x0000000000000000ull;
889 res.w[1] = p_sign | MASK_INF;
890 res.w[0] = 0x0;
894 res.w[1] = 0x7c00000000000000ull;
895 res.w[0] = 0x0000000000000000ull;
903 BID_SWAP128 (res);
904 BID_RETURN (res)
911 res.w[1] = 0x7c00000000000000ull;
912 res.w[0] = 0x0000000000000000ull;
916 res.w[1] = z_sign | MASK_INF;
917 res.w[0] = 0x0;
922 res.w[1] = 0x7c00000000000000ull;
923 res.w[0] = 0x0000000000000000ull;
928 res.w[1] = p_sign | MASK_INF;
929 res.w[0] = 0x0;
935 BID_SWAP128 (res);
936 BID_RETURN (res)
939 res.w[1] = z_sign | MASK_INF;
940 res.w[0] = 0x0;
945 BID_SWAP128 (res);
946 BID_RETURN (res)
958 res.w[1] = p_exp; // preferred exponent
960 res.w[1] = z_exp; // preferred exponent
962 res.w[1] |= z_sign;
963 res.w[0] = 0x0;
966 // res = -0.0
967 res.w[1] |= MASK_SIGN;
968 res.w[0] = 0x0;
970 // res = +0.0
971 // res.w[1] |= 0x0;
972 res.w[0] = 0x0;
979 BID_SWAP128 (res);
980 BID_RETURN (res)
1094 res.w[1] = z_sign | (z_exp & MASK_EXP) | C3.w[1];
1095 res.w[0] = C3.w[0];
1104 res.w[1] = z.w[1]; // & MASK_COEFF, which is redundant
1105 res.w[0] = z.w[0];
1109 __mul_64x64_to_128MACH (res, C3.w[0], ten2k64[scale]);
1112 __mul_128x64_to_128 (res, C3.w[0], ten2k128[scale - 20]);
1116 __mul_128x64_to_128 (res, ten2k64[scale], C3);
1120 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
1126 BID_SWAP128 (res);
1127 BID_RETURN (res)
1293 // truncate C4 to p34 digits into res
1299 round128_19_38 (q4, x0, P128, &res, &incr_exp,
1311 res.w[0] = R192.w[0];
1312 res.w[1] = R192.w[1];
1318 res.w[0] = R256.w[0];
1319 res.w[1] = R256.w[1];
1326 // res is now the coefficient of the result rounded to the destination
1327 // precision, with unbounded exponent; the exponent is e4; q4=digits(res)
1335 // res = (C4 * 10^scale) * 10^expmax
1339 __mul_64x64_to_128MACH (res, C4.w[0], ten2k64[scale]);
1342 __mul_128x64_to_128 (res, C4.w[0], ten2k128[scale - 20]);
1346 __mul_128x64_to_128 (res, ten2k64[scale], C4);
1351 res.w[1] = C4.w[1];
1352 res.w[0] = C4.w[0];
1354 // res is the coefficient of the result rounded to the destination
1362 res.w[1] = p_sign | 0x7800000000000000ull; // +/-inf
1363 res.w[0] = 0x0000000000000000ull;
1366 res.w[1] = p_sign | res.w[1];
1371 e4, &res, pfpsf);
1378 BID_SWAP128 (res);
1379 BID_RETURN (res)
1385 // if e4 < expmin, we must truncate more of res
1395 // the number of decimal digits in res is q4
1396 if (x0 < q4) { // 1 <= x0 <= q4-1 => round res to q4 - x0 digits
1398 round64_2_18 (q4, x0, res.w[0], &R64, &incr_exp,
1406 // res.w[1] = 0; (from above)
1407 res.w[0] = R64;
1410 P128.w[1] = res.w[1];
1411 P128.w[0] = res.w[0];
1412 round128_19_38 (q4, x0, P128, &res, &incr_exp,
1420 // res.w[1] = 0;
1421 res.w[0] = ten2k64[q4 - x0];
1423 res.w[0] = ten2k128[q4 - x0 - 20].w[0];
1424 res.w[1] = ten2k128[q4 - x0 - 20].w[1];
1433 if (res.w[0] < midpoint64[q4 - 1]) { // < 1/2 ulp
1436 } else if (res.w[0] == midpoint64[q4 - 1]) { // = 1/2 ulp
1444 if (res.w[1] < midpoint128[q4 - 20].w[1] ||
1445 (res.w[1] == midpoint128[q4 - 20].w[1] &&
1446 res.w[0] < midpoint128[q4 - 20].w[0])) { // < 1/2 ulp
1449 } else if (res.w[1] == midpoint128[q4 - 20].w[1] &&
1450 res.w[0] == midpoint128[q4 - 20].w[0]) { // = 1/2 ulp
1459 // res = +0.0 * 10^expmin
1460 res.w[1] = 0x0000000000000000ull;
1461 res.w[0] = 0x0000000000000000ull;
1463 // res = +1 * 10^expmin
1464 res.w[1] = 0x0000000000000000ull;
1465 res.w[0] = 0x0000000000000001ull;
1470 res.w[1] = 0;
1471 res.w[0] = 0;
1478 // res = res - 1
1479 res.w[0]--;
1480 if (res.w[0] == 0xffffffffffffffffull)
1481 res.w[1]--;
1490 // res = res + 1
1491 res.w[0]++;
1492 if (res.w[0] == 0)
1493 res.w[1]++;
1533 ; // res and e4 are unchanged
1536 // 64 x 64 res.w[0] * ten2k64[scale]
1537 __mul_64x64_to_128MACH (res, res.w[0], ten2k64[scale]);
1539 // 64 x 128 res.w[0] * ten2k128[scale - 20]
1540 __mul_128x64_to_128 (res, res.w[0], ten2k128[scale - 20]);
1542 } else { // res fits in 128 bits, but 10^scale must fit in 64 bits
1544 __mul_128x64_to_128 (res, ten2k64[scale], res);
1558 res.w[1] = p_sign | ((UINT64) (e4 + 6176) << 49) | res.w[1];
1564 e4, &res, pfpsf);
1571 BID_SWAP128 (res);
1572 BID_RETURN (res)
1575 res.w[1] = p_sign | ((UINT64) (e4 + 6176) << 49) | res.w[1];
1582 e4, &res, pfpsf);
1585 if ((res.w[1] & MASK_COEFF) < 0x0000314dc6448d93ull ||
1586 ((res.w[1] & MASK_COEFF) == 0x0000314dc6448d93ull &&
1587 res.w[0] < 0x38c15b0a00000000ull)) {
1603 p_exp = res.w[1] & MASK_EXP;
1605 // signficand of res in C3
1606 C3.w[1] = res.w[1] & MASK_COEFF;
1607 C3.w[0] = res.w[0];
1620 ; // leave res unchanged
1624 __mul_64x64_to_128MACH (res, C3.w[0], ten2k64[scale]);
1627 __mul_128x64_to_128 (res, C3.w[0], ten2k128[scale - 20]);
1629 res.w[1] = p_sign | (p_exp & MASK_EXP) | res.w[1];
1632 __mul_128x64_to_128 (res, ten2k64[scale], C3);
1633 res.w[1] = p_sign | (p_exp & MASK_EXP) | res.w[1];
1642 BID_SWAP128 (res);
1643 BID_RETURN (res)
1659 res.w[1] = z_sign | 0x7800000000000000ull; // +/-inf
1660 res.w[0] = 0x0000000000000000ull;
1671 res.w[1] = z_sign | C3.w[1];
1672 res.w[0] = C3.w[0];
1677 __mul_64x64_to_128MACH (res, C3.w[0], ten2k64[scale]);
1680 __mul_128x64_to_128 (res, C3.w[0],
1685 __mul_128x64_to_128 (res, ten2k64[scale], C3);
1687 // the coefficient in res has q3 + scale = p34 digits
1690 res.w[1] = z_sign | res.w[1];
1695 e3, &res, pfpsf);
1701 BID_SWAP128 (res);
1702 BID_RETURN (res)
1704 // res = z
1713 res.w[1] = C3.w[1];
1714 res.w[0] = C3.w[0];
1718 __mul_64x64_to_128MACH (res, C3.w[0], ten2k64[scale]);
1721 __mul_128x64_to_128 (res, C3.w[0], ten2k128[scale - 20]);
1725 __mul_128x64_to_128 (res, ten2k64[scale], C3);
1727 // the coefficient in res has q3 + scale digits
1731 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
1736 res.w[1] = z_sign | ((UINT64) (e3 + 6176) << 49) | C3.w[1];
1737 res.w[0] = C3.w[0];
1751 // if ((res.w[1] & MASK_COEFF) != 0x0000314dc6448d93ull ||
1752 // res.w[0] != 0x38c15b0a00000000ull) { // C3 * 10^scale != 10^33
1817 res.w[1] = 0;
1818 res.w[0] = ten2k64[q3 + scale];
1820 res.w[1] = ten2k128[q3 + scale - 20].w[1];
1821 res.w[0] = ten2k128[q3 + scale - 20].w[0];
1823 res.w[0] = res.w[0] - 1; // borrow never occurs
1826 res.w[1] = z_sign | ((UINT64) (e3 + 6176) << 49) | res.w[1];
1880 (res.w[1] & MASK_COEFF) == 0x0000314dc6448d93ull && // 10^33_high
1881 res.w[0] == 0x38c15b0a00000000ull && // 10^33_low
1891 e3, &res, pfpsf);
1897 BID_SWAP128 (res);
1898 BID_RETURN (res)
1908 res.w[1] = C3.w[1];
1909 res.w[0] = C3.w[0];
1913 __mul_64x64_to_128MACH (res, C3.w[0], ten2k64[scale]);
1916 __mul_128x64_to_128 (res, C3.w[0], ten2k128[scale - 20]);
1920 __mul_128x64_to_128 (res, ten2k64[scale], C3);
1925 // now z_sign, z_exp, and res correspond to a z scaled to p34 = 34 digits
1987 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
1991 } else if ((eq_half_ulp && (res.w[0] & 0x01)) || gt_half_ulp) {
1993 res.w[0]++;
1994 if (res.w[0] == 0x0ull)
1995 res.w[1]++;
1997 if ((res.w[1] & MASK_COEFF) == 0x0001ed09bead87c0ull &&
1998 res.w[0] == 0x378d8e6400000000ull) { // coefficient = 10^34
2002 res.w[1] = 0x0000314dc6448d93ull;
2003 res.w[0] = 0x38c15b0a00000000ull;
2006 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2012 } else { // if (eq_half_ulp && !(res.w[0] & 0x01))
2014 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2022 res.w[1] = z_sign | 0x7800000000000000ull; // +/-inf
2023 res.w[0] = 0x0000000000000000ull;
2029 BID_SWAP128 (res);
2030 BID_RETURN (res)
2037 e3, &res, pfpsf);
2038 z_exp = res.w[1] & MASK_EXP;
2042 if (res.w[1] != 0x0000314dc6448d93ull ||
2043 res.w[0] != 0x38c15b0a00000000ull) { // C3 * 10^scale != 10^33
2045 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2049 } else if ((eq_half_ulp && (res.w[0] & 0x01)) || gt_half_ulp) {
2051 res.w[0]--;
2052 if (res.w[0] == 0xffffffffffffffffull)
2053 res.w[1]--;
2054 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2060 } else { // if (eq_half_ulp && !(res.w[0] & 0x01))
2062 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2069 res.w[1] = z_sign | 0x7800000000000000ull; // +/-inf
2070 res.w[0] = 0x0000000000000000ull;
2077 is_midpoint_gt_even, e3, &res,
2084 BID_SWAP128 (res);
2085 BID_RETURN (res)
2094 is_midpoint_gt_even, e3, &res, pfpsf);
2096 z_exp = res.w[1] & MASK_EXP;
2105 res.w[1] = 0x0001ed09bead87c0ull;
2106 res.w[0] = 0x378d8e6400000000ull - C4.w[0];
2109 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2152 res.w[1] =
2154 res.w[0] = 0x378d8e6400000000ull - R64;
2172 res.w[1] = 0x0001ed09bead87c0ull;
2173 res.w[0] = 0x378d8e6400000000ull - R64;
2197 res.w[1] = z_sign | 0x7800000000000000ull; // +/-inf
2198 res.w[0] = 0x0000000000000000ull;
2205 is_midpoint_gt_even, e3, &res,
2212 BID_SWAP128 (res);
2213 BID_RETURN (res)
2217 res.w[1] =
2218 z_sign | ((UINT64) (e3 + 6176) << 49) | res.w[1];
2224 is_midpoint_gt_even, e3, &res,
2227 z_exp = res.w[1] & MASK_EXP;
2237 // if (lt_half_ulp || eq_half_ulp) res = 10^33 stays unchanged
2240 if (gt_half_ulp) { // res = 10^33 - 1
2241 res.w[1] = 0x0000314dc6448d93ull;
2242 res.w[0] = 0x38c15b09ffffffffull;
2244 res.w[1] = 0x0000314dc6448d93ull;
2245 res.w[0] = 0x38c15b0a00000000ull;
2247 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2263 is_midpoint_gt_even, e3, &res,
2265 z_exp = res.w[1] & MASK_EXP;
2274 res.w[1] = z_sign | (z_exp & MASK_EXP) | res.w[1];
2279 BID_SWAP128 (res);
2280 BID_RETURN (res)
2296 // calculate res = C3 * 10^scale
2329 // calculate res = C3 * 10^scale
2338 res.w[1] = C3.w[1];
2339 res.w[0] = C3.w[0];
2343 __mul_64x64_to_128MACH (res, C3.w[0], ten2k64[scale]);
2346 __mul_128x64_to_128 (res, C3.w[0], ten2k128[scale - 20]);
2350 __mul_128x64_to_128 (res, ten2k64[scale], C3);
2354 // now res = C3 * 10^scale and e3 = e3 - scale
2445 // now add C3 * 10^scale in res and the signed top (q4-x0) digits of C4,
2448 lsb = res.w[0] & 0x01; // lsb of C3 * 10^scale
2450 res.w[0] = res.w[0] + R128.w[0];
2451 res.w[1] = res.w[1] + R128.w[1];
2452 if (res.w[0] < R128.w[0])
2453 res.w[1]++; // carry
2454 // if res > 10^34 - 1 need to increase x0 and decrease scale by 1
2455 if (res.w[1] > 0x0001ed09bead87c0ull ||
2456 (res.w[1] == 0x0001ed09bead87c0ull &&
2457 res.w[0] > 0x378d8e63ffffffffull)) {
2467 P128.w[1] = res.w[1];
2468 P128.w[0] = res.w[0];
2469 round128_19_38 (35, 1, P128, &res, &incr_exp,
2477 // res = res - 1
2478 res.w[0]--;
2479 if (res.w[0] == 0xffffffffffffffffull)
2480 res.w[1]--;
2489 // res = res + 1
2490 res.w[0]++;
2491 if (res.w[0] == 0)
2492 res.w[1]++;
2537 res.w[1] = res.w[1] & MASK_COEFF;
2540 // res = res + 1
2543 res.w[0]++;
2544 if (res.w[0] == 0x0)
2545 res.w[1]++;
2547 if (res.w[1] == 0x0001ed09bead87c0ull &&
2548 res.w[0] == 0x378d8e6400000000ull) {
2549 // res = 10^34 => rounding overflow
2550 res.w[1] = 0x0000314dc6448d93ull;
2551 res.w[0] = 0x38c15b0a00000000ull; // 10^33
2555 // res = res - 1
2558 res.w[0]--;
2559 if (res.w[0] == 0xffffffffffffffffull)
2560 res.w[1]--;
2563 if (res.w[1] == 0x0ull && res.w[0] == 0x0ull) {
2569 res.w[1] = 0x0;
2570 res.w[0] = 0x0;
2575 BID_SWAP128 (res);
2576 BID_RETURN (res)
2584 lsb = res.w[0] & 0x01; // lsb of C3 * 10^scale; R128 contains rounded C4
2587 tmp64 = res.w[0];
2588 res.w[0] = res.w[0] - R128.w[0];
2589 res.w[1] = res.w[1] - R128.w[1];
2590 if (res.w[0] > tmp64)
2591 res.w[1]--; // borrow
2592 // if res < 10^33 and exp > expmin need to decrease x0 and
2594 if (e3 > expmin && ((res.w[1] < 0x0000314dc6448d93ull ||
2595 (res.w[1] == 0x0000314dc6448d93ull &&
2596 res.w[0] < 0x38c15b0a00000000ull)) ||
2598 && res.w[1] == 0x0000314dc6448d93ull
2599 && res.w[0] == 0x38c15b0a00000000ull))
2633 // res = res + 1
2634 res.w[0]++;
2635 if (res.w[0] == 0x0)
2636 res.w[1]++;
2638 if (res.w[1] == 0x0001ed09bead87c0ull &&
2639 res.w[0] == 0x378d8e6400000000ull) {
2640 // res = 10^34 => rounding overflow
2641 res.w[1] = 0x0000314dc6448d93ull;
2642 res.w[0] = 0x38c15b0a00000000ull; // 10^33
2646 // res = res - 1
2647 res.w[0]--;
2648 if (res.w[0] == 0xffffffffffffffffull)
2649 res.w[1]--;
2652 if (res.w[1] == 0x0ull && res.w[0] == 0x0ull) {
2658 res.w[1] = 0x0;
2659 res.w[0] = 0x0;
2664 BID_SWAP128 (res);
2665 BID_RETURN (res)
2676 if ((res.w[1] & MASK_COEFF) < 0x0000314dc6448d93ull ||
2677 ((res.w[1] & MASK_COEFF) == 0x0000314dc6448d93ull &&
2678 res.w[0] < 0x38c15b0a00000000ull)) {
2682 // the result is tiny, so we must truncate more of res
2693 // determine the number of decimal digits in res
2694 if (res.w[1] == 0x0) {
2697 if (res.w[0] < ten2k64[ind]) {
2702 } else if (res.w[1] < ten2k128[0].w[1] ||
2703 (res.w[1] == ten2k128[0].w[1]
2704 && res.w[0] < ten2k128[0].w[0])) {
2709 if (res.w[1] < ten2k128[ind].w[1] ||
2710 (res.w[1] == ten2k128[ind].w[1] &&
2711 res.w[0] < ten2k128[ind].w[0])) {
2723 // the most significant decimal digit in res has the weight
2731 res.w[1] = 0x0;
2732 res.w[0] = 0x1;
2736 round64_2_18 (ind, x0, res.w[0], &R64, &incr_exp,
2744 res.w[1] = 0;
2745 res.w[0] = R64;
2748 P128.w[1] = res.w[1];
2749 P128.w[0] = res.w[0];
2750 round128_19_38 (ind, x0, P128, &res, &incr_exp,
2757 res.w[0] = ten2k64[ind - x0];
2758 // res.w[1] stays 0
2760 res.w[0] = ten2k128[ind - x0 - 20].w[0];
2761 res.w[1] = ten2k128[ind - x0 - 20].w[1];
2768 // res = res - 1
2769 res.w[0]--;
2770 if (res.w[0] == 0xffffffffffffffffull)
2771 res.w[1]--;
2780 // res = res + 1
2781 res.w[0]++;
2782 if (res.w[0] == 0)
2783 res.w[1]++;
2835 if (res.w[1] == 0x0001ed09bead87c0ull &&
2836 res.w[0] == 0x378d8e6400000000ull) { // if res = 10^34
2837 res.w[1] = 0x0000314dc6448d93ull; // res = 10^33
2838 res.w[0] = 0x38c15b0a00000000ull;
2841 res.w[1] = z_sign | ((UINT64) (e3 + 6176) << 49) | res.w[1];
2844 res.w[1] = z_sign | 0x7800000000000000ull; // +/-inf
2845 res.w[0] = 0x0000000000000000ull;
2853 e3, &res, pfpsf);
2859 BID_SWAP128 (res);
2860 BID_RETURN (res)
2902 &is_inexact_gt_midpoint, pfpsf, &res);
2907 BID_SWAP128 (res);
2908 BID_RETURN (res)
2918 // truncate C4 to p34 digits into res
2924 round128_19_38 (q4, x0, P128, &res, &incr_exp,
2936 res.w[0] = R192.w[0];
2937 res.w[1] = R192.w[1];
2943 res.w[0] = R256.w[0];
2944 res.w[1] = R256.w[1];
2957 if (res.w[1] != 0x0000314dc6448d93ull ||
2958 res.w[0] != 0x38c15b0a00000000ull) { // res != 10^33
2960 } else { // res = 10^33 and exact is a special case
2961 // if C3 < 1/2 ulp then res = 10^33 and is_inexact_gt_midpoint = 1
2962 // if C3 = 1/2 ulp then res = 10^33 and is_midpoint_lt_even = 1
2963 // if C3 > 1/2 ulp then res = 10^34-1 and is_inexact_lt_midpoint = 1
2966 // res = 10^33, unchanged
2971 // res = 10^33, unchanged
2974 // res = 10^33, unchanged
2977 res.w[1] = 0x0001ed09bead87c0ull; // 10^34 - 1
2978 res.w[0] = 0x378d8e63ffffffffull;
2986 // res = 10^33, unchanged
2990 // res = 10^33, unchanged
2993 res.w[1] = 0x0001ed09bead87c0ull; // 10^34 - 1
2994 res.w[0] = 0x378d8e63ffffffffull;
3004 // needs correction: res = res - 1
3005 res.w[0] = res.w[0] - 1;
3006 if (res.w[0] == 0xffffffffffffffffull)
3007 res.w[1]--;
3010 if (res.w[1] == 0x0000314dc6448d93ull &&
3011 res.w[0] == 0x38c15b09ffffffffull) {
3012 res.w[1] = 0x0001ed09bead87c0ull; // 10^34 - 1
3013 res.w[0] = 0x378d8e63ffffffffull;
3024 // needs correction: res = res + 1 (cannot cross in the next binade)
3025 res.w[0] = res.w[0] + 1;
3026 if (res.w[0] == 0x0000000000000000ull)
3027 res.w[1]++;
3039 res.w[1] = p_sign | 0x7800000000000000ull;
3040 res.w[0] = 0x0000000000000000ull;
3044 res.w[1] = p_sign | (p_exp & MASK_EXP) | res.w[1];
3051 e4, &res, pfpsf);
3062 BID_SWAP128 (res);
3063 BID_RETURN (res)
3163 // res = res + 1
3176 // res = res - 1
3208 res.w[1] = R256.w[1];
3209 res.w[0] = R256.w[0];
3253 res.w[1] = R128.w[1];
3254 res.w[0] = R128.w[0];
3259 // res = res - 1
3260 res.w[0]--;
3261 if (res.w[0] == 0xffffffffffffffffull)
3262 res.w[1]--;
3270 if (res.w[1] == 0x0000314dc6448d93ull &&
3271 res.w[0] == 0x38c15b09ffffffffull) { // 10^33 - 1
3272 res.w[1] = 0x0001ed09bead87c0ull; // 10^34 - 1
3273 res.w[0] = 0x378d8e63ffffffffull;
3278 // res = res + 1
3279 res.w[0]++;
3280 if (res.w[0] == 0)
3281 res.w[1]++;
3321 // (-1)^p_sign * res * 10^0
3322 P128.w[1] = p_sign | 0x3040000000000000ull | res.w[1];
3323 P128.w[0] = res.w[0];
3337 // is (-1)^p_sign * res * 10^e4
3338 res.w[1] = p_sign | ((UINT64) (e4 + 6176) << 49) | res.w[1]; // RN
3339 // res.w[0] unchanged;
3340 // Note: res is correct only if expmin <= e4 <= expmax
3341 ind = p34; // the number of decimal digits in the signifcand of res
3344 // res and we know its tininess:
3345 // res = (-1)^p_sign * significand * 10^e4,
3347 // Note: res is correct only if expmin <= e4 <= expmax
3352 res.w[1] = p_sign | 0x7800000000000000ull;
3353 res.w[0] = 0x0000000000000000ull;
3359 BID_SWAP128 (res);
3360 BID_RETURN (res)
3368 x0 = expmin - e4; // x0 >= 1; the number of digits to chop off of res
3383 // nothing is left of res when moving the decimal point left x0 digits
3385 res.w[1] = p_sign | 0x0000000000000000ull;
3386 res.w[0] = 0x0000000000000000ull;
3390 // compare the ind-digit value in the significand of res with
3392 // less than, equal to, or greater than 1/2 ulp (significand of res)
3393 R128.w[1] = res.w[1] & MASK_COEFF;
3394 R128.w[0] = res.w[0];
3422 // res = +0.0 * 10^expmin
3423 res.w[1] = 0x0000000000000000ull;
3424 res.w[0] = 0x0000000000000000ull;
3426 // res = +1 * 10^expmin
3427 res.w[1] = 0x0000000000000000ull;
3428 res.w[0] = 0x0000000000000001ull;
3430 res.w[1] = p_sign | res.w[1];
3436 round64_2_18 (ind, x0, res.w[0], &R64, &incr_exp,
3440 res.w[1] = 0x0;
3441 res.w[0] = R64;
3443 P128.w[1] = res.w[1] & MASK_COEFF;
3444 P128.w[0] = res.w[0];
3445 round128_19_38 (ind, x0, P128, &res, &incr_exp,
3455 P128.w[1] = res.w[1] & MASK_COEFF;
3456 P128.w[0] = res.w[0];
3457 __mul_64x128_to_128 (res, ten2k64[1], P128);
3459 res.w[1] =
3460 p_sign | ((UINT64) (e4 + 6176) << 49) | (res.
3465 // res = res - 1
3466 res.w[0]--;
3467 if (res.w[0] == 0xffffffffffffffffull)
3468 res.w[1]--;
3477 // res = res + 1
3478 res.w[0]++;
3479 if (res.w[0] == 0)
3480 res.w[1]++;
3515 // res contains the correct result
3522 e4, &res, pfpsf);
3535 BID_SWAP128 (res);
3536 BID_RETURN (res)
3548 &is_inexact_gt_midpoint, pfpsf, &res);
3553 BID_SWAP128 (res);
3554 BID_RETURN (res)
3566 BID_SWAP128 (res);
3567 BID_RETURN (res)
3589 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3594 &res, &x, &y, &z
3598 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3604 BID_RETURN (res);
3625 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3634 &res, &x1, &y1, &z1
3641 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3647 BID_RETURN (res);
3669 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3677 &res, &x1, &y1, &z
3683 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3689 BID_RETURN (res);
3710 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3718 &res, &x1, py, &z1
3724 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3730 BID_RETURN (res);
3751 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3758 &res, &x1, py, pz
3763 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3769 BID_RETURN (res);
3790 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3798 &res, px, &y1, &z1
3804 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3810 BID_RETURN (res);
3831 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3838 &res, px, &y1, pz
3843 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3849 BID_RETURN (res);
3870 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
3877 &res, px, py, &z1
3882 res = bid128_ext_fma (&is_midpoint_lt_even, &is_midpoint_gt_even,
3888 BID_RETURN (res);
4119 UINT128 res = { {0xbaddbaddbaddbaddull, 0xbaddbaddbaddbaddull} };
4142 &res, &x, &y, &z
4146 res = bid128_ext_fma (&is_midpoint_lt_even0, &is_midpoint_gt_even0,
4155 ((res.w[HIGH_128W] & MASK_NAN) == MASK_NAN) || //res=QNaN (cannot be SNaN)
4156 ((res.w[HIGH_128W] & MASK_ANY_INF) == MASK_INF)) { // result is infinity
4158 bid128_to_bid64 (&res1, &res _RND_MODE_ARG _EXC_FLAGS_ARG);
4160 res1 = bid128_to_bid64 (res _RND_MODE_ARG _EXC_FLAGS_ARG);
4186 sign = res.w[HIGH_128W] & MASK_SIGN; // 0 for positive, MASK_SIGN for negative
4187 exp = res.w[HIGH_128W] & MASK_EXP; // biased and shifted left 49 bits
4189 C.w[1] = res.w[HIGH_128W] & MASK_COEFF;
4190 C.w[0] = res.w[LOW_128W];
4196 bid128_to_bid64 (&res1, &res _RND_MODE_ARG _EXC_FLAGS_ARG);
4198 res1 = bid128_to_bid64 (res _RND_MODE_ARG _EXC_FLAGS_ARG);
4208 // res = res - 1
4275 // res = res - 1
4285 // res = res + 1
4337 // we must truncate more of res
4348 if (x0 < q) { // 1 <= x0 <= q-1 => round res to q - x0 digits
4373 // res = +0.0 * 10^expmin16
4376 // res = +1 * 10^expmin16
4389 // res = res - 1
4395 // res = res + 1
4445 // res = res + 1
4450 if (res1 < 0x0020000000000000ull) { // res < 2^53