fp_div_impl.inc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. //===-- fp_div_impl.inc - Floating point division -----------------*- C -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements soft-float division with the IEEE-754 default
  10. // rounding (to nearest, ties to even).
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "fp_lib.h"
  14. // The __divXf3__ function implements Newton-Raphson floating point division.
  15. // It uses 3 iterations for float32, 4 for float64 and 5 for float128,
  16. // respectively. Due to number of significant bits being roughly doubled
  17. // every iteration, the two modes are supported: N full-width iterations (as
  18. // it is done for float32 by default) and (N-1) half-width iteration plus one
  19. // final full-width iteration. It is expected that half-width integer
  20. // operations (w.r.t rep_t size) can be performed faster for some hardware but
  21. // they require error estimations to be computed separately due to larger
  22. // computational errors caused by truncating intermediate results.
  23. // Half the bit-size of rep_t
  24. #define HW (typeWidth / 2)
  25. // rep_t-sized bitmask with lower half of bits set to ones
  26. #define loMask (REP_C(-1) >> HW)
  27. #if NUMBER_OF_FULL_ITERATIONS < 1
  28. #error At least one full iteration is required
  29. #endif
  30. static __inline fp_t __divXf3__(fp_t a, fp_t b) {
  31. const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
  32. const unsigned int bExponent = toRep(b) >> significandBits & maxExponent;
  33. const rep_t quotientSign = (toRep(a) ^ toRep(b)) & signBit;
  34. rep_t aSignificand = toRep(a) & significandMask;
  35. rep_t bSignificand = toRep(b) & significandMask;
  36. int scale = 0;
  37. // Detect if a or b is zero, denormal, infinity, or NaN.
  38. if (aExponent - 1U >= maxExponent - 1U ||
  39. bExponent - 1U >= maxExponent - 1U) {
  40. const rep_t aAbs = toRep(a) & absMask;
  41. const rep_t bAbs = toRep(b) & absMask;
  42. // NaN / anything = qNaN
  43. if (aAbs > infRep)
  44. return fromRep(toRep(a) | quietBit);
  45. // anything / NaN = qNaN
  46. if (bAbs > infRep)
  47. return fromRep(toRep(b) | quietBit);
  48. if (aAbs == infRep) {
  49. // infinity / infinity = NaN
  50. if (bAbs == infRep)
  51. return fromRep(qnanRep);
  52. // infinity / anything else = +/- infinity
  53. else
  54. return fromRep(aAbs | quotientSign);
  55. }
  56. // anything else / infinity = +/- 0
  57. if (bAbs == infRep)
  58. return fromRep(quotientSign);
  59. if (!aAbs) {
  60. // zero / zero = NaN
  61. if (!bAbs)
  62. return fromRep(qnanRep);
  63. // zero / anything else = +/- zero
  64. else
  65. return fromRep(quotientSign);
  66. }
  67. // anything else / zero = +/- infinity
  68. if (!bAbs)
  69. return fromRep(infRep | quotientSign);
  70. // One or both of a or b is denormal. The other (if applicable) is a
  71. // normal number. Renormalize one or both of a and b, and set scale to
  72. // include the necessary exponent adjustment.
  73. if (aAbs < implicitBit)
  74. scale += normalize(&aSignificand);
  75. if (bAbs < implicitBit)
  76. scale -= normalize(&bSignificand);
  77. }
  78. // Set the implicit significand bit. If we fell through from the
  79. // denormal path it was already set by normalize( ), but setting it twice
  80. // won't hurt anything.
  81. aSignificand |= implicitBit;
  82. bSignificand |= implicitBit;
  83. int writtenExponent = (aExponent - bExponent + scale) + exponentBias;
  84. const rep_t b_UQ1 = bSignificand << (typeWidth - significandBits - 1);
  85. // Align the significand of b as a UQ1.(n-1) fixed-point number in the range
  86. // [1.0, 2.0) and get a UQ0.n approximate reciprocal using a small minimax
  87. // polynomial approximation: x0 = 3/4 + 1/sqrt(2) - b/2.
  88. // The max error for this approximation is achieved at endpoints, so
  89. // abs(x0(b) - 1/b) <= abs(x0(1) - 1/1) = 3/4 - 1/sqrt(2) = 0.04289...,
  90. // which is about 4.5 bits.
  91. // The initial approximation is between x0(1.0) = 0.9571... and x0(2.0) = 0.4571...
  92. // Then, refine the reciprocal estimate using a quadratically converging
  93. // Newton-Raphson iteration:
  94. // x_{n+1} = x_n * (2 - x_n * b)
  95. //
  96. // Let b be the original divisor considered "in infinite precision" and
  97. // obtained from IEEE754 representation of function argument (with the
  98. // implicit bit set). Corresponds to rep_t-sized b_UQ1 represented in
  99. // UQ1.(W-1).
  100. //
  101. // Let b_hw be an infinitely precise number obtained from the highest (HW-1)
  102. // bits of divisor significand (with the implicit bit set). Corresponds to
  103. // half_rep_t-sized b_UQ1_hw represented in UQ1.(HW-1) that is a **truncated**
  104. // version of b_UQ1.
  105. //
  106. // Let e_n := x_n - 1/b_hw
  107. // E_n := x_n - 1/b
  108. // abs(E_n) <= abs(e_n) + (1/b_hw - 1/b)
  109. // = abs(e_n) + (b - b_hw) / (b*b_hw)
  110. // <= abs(e_n) + 2 * 2^-HW
  111. // rep_t-sized iterations may be slower than the corresponding half-width
  112. // variant depending on the handware and whether single/double/quad precision
  113. // is selected.
  114. // NB: Using half-width iterations increases computation errors due to
  115. // rounding, so error estimations have to be computed taking the selected
  116. // mode into account!
  117. #if NUMBER_OF_HALF_ITERATIONS > 0
  118. // Starting with (n-1) half-width iterations
  119. const half_rep_t b_UQ1_hw = bSignificand >> (significandBits + 1 - HW);
  120. // C is (3/4 + 1/sqrt(2)) - 1 truncated to W0 fractional bits as UQ0.HW
  121. // with W0 being either 16 or 32 and W0 <= HW.
  122. // That is, C is the aforementioned 3/4 + 1/sqrt(2) constant (from which
  123. // b/2 is subtracted to obtain x0) wrapped to [0, 1) range.
  124. #if defined(SINGLE_PRECISION)
  125. // Use 16-bit initial estimation in case we are using half-width iterations
  126. // for float32 division. This is expected to be useful for some 16-bit
  127. // targets. Not used by default as it requires performing more work during
  128. // rounding and would hardly help on regular 32- or 64-bit targets.
  129. const half_rep_t C_hw = HALF_REP_C(0x7504);
  130. #else
  131. // HW is at least 32. Shifting into the highest bits if needed.
  132. const half_rep_t C_hw = HALF_REP_C(0x7504F333) << (HW - 32);
  133. #endif
  134. // b >= 1, thus an upper bound for 3/4 + 1/sqrt(2) - b/2 is about 0.9572,
  135. // so x0 fits to UQ0.HW without wrapping.
  136. half_rep_t x_UQ0_hw = C_hw - (b_UQ1_hw /* exact b_hw/2 as UQ0.HW */);
  137. // An e_0 error is comprised of errors due to
  138. // * x0 being an inherently imprecise first approximation of 1/b_hw
  139. // * C_hw being some (irrational) number **truncated** to W0 bits
  140. // Please note that e_0 is calculated against the infinitely precise
  141. // reciprocal of b_hw (that is, **truncated** version of b).
  142. //
  143. // e_0 <= 3/4 - 1/sqrt(2) + 2^-W0
  144. // By construction, 1 <= b < 2
  145. // f(x) = x * (2 - b*x) = 2*x - b*x^2
  146. // f'(x) = 2 * (1 - b*x)
  147. //
  148. // On the [0, 1] interval, f(0) = 0,
  149. // then it increses until f(1/b) = 1 / b, maximum on (0, 1),
  150. // then it decreses to f(1) = 2 - b
  151. //
  152. // Let g(x) = x - f(x) = b*x^2 - x.
  153. // On (0, 1/b), g(x) < 0 <=> f(x) > x
  154. // On (1/b, 1], g(x) > 0 <=> f(x) < x
  155. //
  156. // For half-width iterations, b_hw is used instead of b.
  157. REPEAT_N_TIMES(NUMBER_OF_HALF_ITERATIONS, {
  158. // corr_UQ1_hw can be **larger** than 2 - b_hw*x by at most 1*Ulp
  159. // of corr_UQ1_hw.
  160. // "0.0 - (...)" is equivalent to "2.0 - (...)" in UQ1.(HW-1).
  161. // On the other hand, corr_UQ1_hw should not overflow from 2.0 to 0.0 provided
  162. // no overflow occurred earlier: ((rep_t)x_UQ0_hw * b_UQ1_hw >> HW) is
  163. // expected to be strictly positive because b_UQ1_hw has its highest bit set
  164. // and x_UQ0_hw should be rather large (it converges to 1/2 < 1/b_hw <= 1).
  165. half_rep_t corr_UQ1_hw = 0 - ((rep_t)x_UQ0_hw * b_UQ1_hw >> HW);
  166. // Now, we should multiply UQ0.HW and UQ1.(HW-1) numbers, naturally
  167. // obtaining an UQ1.(HW-1) number and proving its highest bit could be
  168. // considered to be 0 to be able to represent it in UQ0.HW.
  169. // From the above analysis of f(x), if corr_UQ1_hw would be represented
  170. // without any intermediate loss of precision (that is, in twice_rep_t)
  171. // x_UQ0_hw could be at most [1.]000... if b_hw is exactly 1.0 and strictly
  172. // less otherwise. On the other hand, to obtain [1.]000..., one have to pass
  173. // 1/b_hw == 1.0 to f(x), so this cannot occur at all without overflow (due
  174. // to 1.0 being not representable as UQ0.HW).
  175. // The fact corr_UQ1_hw was virtually round up (due to result of
  176. // multiplication being **first** truncated, then negated - to improve
  177. // error estimations) can increase x_UQ0_hw by up to 2*Ulp of x_UQ0_hw.
  178. x_UQ0_hw = (rep_t)x_UQ0_hw * corr_UQ1_hw >> (HW - 1);
  179. // Now, either no overflow occurred or x_UQ0_hw is 0 or 1 in its half_rep_t
  180. // representation. In the latter case, x_UQ0_hw will be either 0 or 1 after
  181. // any number of iterations, so just subtract 2 from the reciprocal
  182. // approximation after last iteration.
  183. // In infinite precision, with 0 <= eps1, eps2 <= U = 2^-HW:
  184. // corr_UQ1_hw = 2 - (1/b_hw + e_n) * b_hw + 2*eps1
  185. // = 1 - e_n * b_hw + 2*eps1
  186. // x_UQ0_hw = (1/b_hw + e_n) * (1 - e_n*b_hw + 2*eps1) - eps2
  187. // = 1/b_hw - e_n + 2*eps1/b_hw + e_n - e_n^2*b_hw + 2*e_n*eps1 - eps2
  188. // = 1/b_hw + 2*eps1/b_hw - e_n^2*b_hw + 2*e_n*eps1 - eps2
  189. // e_{n+1} = -e_n^2*b_hw + 2*eps1/b_hw + 2*e_n*eps1 - eps2
  190. // = 2*e_n*eps1 - (e_n^2*b_hw + eps2) + 2*eps1/b_hw
  191. // \------ >0 -------/ \-- >0 ---/
  192. // abs(e_{n+1}) <= 2*abs(e_n)*U + max(2*e_n^2 + U, 2 * U)
  193. })
  194. // For initial half-width iterations, U = 2^-HW
  195. // Let abs(e_n) <= u_n * U,
  196. // then abs(e_{n+1}) <= 2 * u_n * U^2 + max(2 * u_n^2 * U^2 + U, 2 * U)
  197. // u_{n+1} <= 2 * u_n * U + max(2 * u_n^2 * U + 1, 2)
  198. // Account for possible overflow (see above). For an overflow to occur for the
  199. // first time, for "ideal" corr_UQ1_hw (that is, without intermediate
  200. // truncation), the result of x_UQ0_hw * corr_UQ1_hw should be either maximum
  201. // value representable in UQ0.HW or less by 1. This means that 1/b_hw have to
  202. // be not below that value (see g(x) above), so it is safe to decrement just
  203. // once after the final iteration. On the other hand, an effective value of
  204. // divisor changes after this point (from b_hw to b), so adjust here.
  205. x_UQ0_hw -= 1U;
  206. rep_t x_UQ0 = (rep_t)x_UQ0_hw << HW;
  207. x_UQ0 -= 1U;
  208. #else
  209. // C is (3/4 + 1/sqrt(2)) - 1 truncated to 32 fractional bits as UQ0.n
  210. const rep_t C = REP_C(0x7504F333) << (typeWidth - 32);
  211. rep_t x_UQ0 = C - b_UQ1;
  212. // E_0 <= 3/4 - 1/sqrt(2) + 2 * 2^-32
  213. #endif
  214. // Error estimations for full-precision iterations are calculated just
  215. // as above, but with U := 2^-W and taking extra decrementing into account.
  216. // We need at least one such iteration.
  217. #ifdef USE_NATIVE_FULL_ITERATIONS
  218. REPEAT_N_TIMES(NUMBER_OF_FULL_ITERATIONS, {
  219. rep_t corr_UQ1 = 0 - ((twice_rep_t)x_UQ0 * b_UQ1 >> typeWidth);
  220. x_UQ0 = (twice_rep_t)x_UQ0 * corr_UQ1 >> (typeWidth - 1);
  221. })
  222. #else
  223. #if NUMBER_OF_FULL_ITERATIONS != 1
  224. #error Only a single emulated full iteration is supported
  225. #endif
  226. #if !(NUMBER_OF_HALF_ITERATIONS > 0)
  227. // Cannot normally reach here: only one full-width iteration is requested and
  228. // the total number of iterations should be at least 3 even for float32.
  229. #error Check NUMBER_OF_HALF_ITERATIONS, NUMBER_OF_FULL_ITERATIONS and USE_NATIVE_FULL_ITERATIONS.
  230. #endif
  231. // Simulating operations on a twice_rep_t to perform a single final full-width
  232. // iteration. Using ad-hoc multiplication implementations to take advantage
  233. // of particular structure of operands.
  234. rep_t blo = b_UQ1 & loMask;
  235. // x_UQ0 = x_UQ0_hw * 2^HW - 1
  236. // x_UQ0 * b_UQ1 = (x_UQ0_hw * 2^HW) * (b_UQ1_hw * 2^HW + blo) - b_UQ1
  237. //
  238. // <--- higher half ---><--- lower half --->
  239. // [x_UQ0_hw * b_UQ1_hw]
  240. // + [ x_UQ0_hw * blo ]
  241. // - [ b_UQ1 ]
  242. // = [ result ][.... discarded ...]
  243. rep_t corr_UQ1 = 0U - ( (rep_t)x_UQ0_hw * b_UQ1_hw
  244. + ((rep_t)x_UQ0_hw * blo >> HW)
  245. - REP_C(1)); // account for *possible* carry
  246. rep_t lo_corr = corr_UQ1 & loMask;
  247. rep_t hi_corr = corr_UQ1 >> HW;
  248. // x_UQ0 * corr_UQ1 = (x_UQ0_hw * 2^HW) * (hi_corr * 2^HW + lo_corr) - corr_UQ1
  249. x_UQ0 = ((rep_t)x_UQ0_hw * hi_corr << 1)
  250. + ((rep_t)x_UQ0_hw * lo_corr >> (HW - 1))
  251. - REP_C(2); // 1 to account for the highest bit of corr_UQ1 can be 1
  252. // 1 to account for possible carry
  253. // Just like the case of half-width iterations but with possibility
  254. // of overflowing by one extra Ulp of x_UQ0.
  255. x_UQ0 -= 1U;
  256. // ... and then traditional fixup by 2 should work
  257. // On error estimation:
  258. // abs(E_{N-1}) <= (u_{N-1} + 2 /* due to conversion e_n -> E_n */) * 2^-HW
  259. // + (2^-HW + 2^-W))
  260. // abs(E_{N-1}) <= (u_{N-1} + 3.01) * 2^-HW
  261. // Then like for the half-width iterations:
  262. // With 0 <= eps1, eps2 < 2^-W
  263. // E_N = 4 * E_{N-1} * eps1 - (E_{N-1}^2 * b + 4 * eps2) + 4 * eps1 / b
  264. // abs(E_N) <= 2^-W * [ 4 * abs(E_{N-1}) + max(2 * abs(E_{N-1})^2 * 2^W + 4, 8)) ]
  265. // abs(E_N) <= 2^-W * [ 4 * (u_{N-1} + 3.01) * 2^-HW + max(4 + 2 * (u_{N-1} + 3.01)^2, 8) ]
  266. #endif
  267. // Finally, account for possible overflow, as explained above.
  268. x_UQ0 -= 2U;
  269. // u_n for different precisions (with N-1 half-width iterations):
  270. // W0 is the precision of C
  271. // u_0 = (3/4 - 1/sqrt(2) + 2^-W0) * 2^HW
  272. // Estimated with bc:
  273. // define half1(un) { return 2.0 * (un + un^2) / 2.0^hw + 1.0; }
  274. // define half2(un) { return 2.0 * un / 2.0^hw + 2.0; }
  275. // define full1(un) { return 4.0 * (un + 3.01) / 2.0^hw + 2.0 * (un + 3.01)^2 + 4.0; }
  276. // define full2(un) { return 4.0 * (un + 3.01) / 2.0^hw + 8.0; }
  277. // | f32 (0 + 3) | f32 (2 + 1) | f64 (3 + 1) | f128 (4 + 1)
  278. // u_0 | < 184224974 | < 2812.1 | < 184224974 | < 791240234244348797
  279. // u_1 | < 15804007 | < 242.7 | < 15804007 | < 67877681371350440
  280. // u_2 | < 116308 | < 2.81 | < 116308 | < 499533100252317
  281. // u_3 | < 7.31 | | < 7.31 | < 27054456580
  282. // u_4 | | | | < 80.4
  283. // Final (U_N) | same as u_3 | < 72 | < 218 | < 13920
  284. // Add 2 to U_N due to final decrement.
  285. #if defined(SINGLE_PRECISION) && NUMBER_OF_HALF_ITERATIONS == 2 && NUMBER_OF_FULL_ITERATIONS == 1
  286. #define RECIPROCAL_PRECISION REP_C(74)
  287. #elif defined(SINGLE_PRECISION) && NUMBER_OF_HALF_ITERATIONS == 0 && NUMBER_OF_FULL_ITERATIONS == 3
  288. #define RECIPROCAL_PRECISION REP_C(10)
  289. #elif defined(DOUBLE_PRECISION) && NUMBER_OF_HALF_ITERATIONS == 3 && NUMBER_OF_FULL_ITERATIONS == 1
  290. #define RECIPROCAL_PRECISION REP_C(220)
  291. #elif defined(QUAD_PRECISION) && NUMBER_OF_HALF_ITERATIONS == 4 && NUMBER_OF_FULL_ITERATIONS == 1
  292. #define RECIPROCAL_PRECISION REP_C(13922)
  293. #else
  294. #error Invalid number of iterations
  295. #endif
  296. // Suppose 1/b - P * 2^-W < x < 1/b + P * 2^-W
  297. x_UQ0 -= RECIPROCAL_PRECISION;
  298. // Now 1/b - (2*P) * 2^-W < x < 1/b
  299. // FIXME Is x_UQ0 still >= 0.5?
  300. rep_t quotient_UQ1, dummy;
  301. wideMultiply(x_UQ0, aSignificand << 1, &quotient_UQ1, &dummy);
  302. // Now, a/b - 4*P * 2^-W < q < a/b for q=<quotient_UQ1:dummy> in UQ1.(SB+1+W).
  303. // quotient_UQ1 is in [0.5, 2.0) as UQ1.(SB+1),
  304. // adjust it to be in [1.0, 2.0) as UQ1.SB.
  305. rep_t residualLo;
  306. if (quotient_UQ1 < (implicitBit << 1)) {
  307. // Highest bit is 0, so just reinterpret quotient_UQ1 as UQ1.SB,
  308. // effectively doubling its value as well as its error estimation.
  309. residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
  310. writtenExponent -= 1;
  311. aSignificand <<= 1;
  312. } else {
  313. // Highest bit is 1 (the UQ1.(SB+1) value is in [1, 2)), convert it
  314. // to UQ1.SB by right shifting by 1. Least significant bit is omitted.
  315. quotient_UQ1 >>= 1;
  316. residualLo = (aSignificand << significandBits) - quotient_UQ1 * bSignificand;
  317. }
  318. // NB: residualLo is calculated above for the normal result case.
  319. // It is re-computed on denormal path that is expected to be not so
  320. // performance-sensitive.
  321. // Now, q cannot be greater than a/b and can differ by at most 8*P * 2^-W + 2^-SB
  322. // Each NextAfter() increments the floating point value by at least 2^-SB
  323. // (more, if exponent was incremented).
  324. // Different cases (<---> is of 2^-SB length, * = a/b that is shown as a midpoint):
  325. // q
  326. // | | * | | | | |
  327. // <---> 2^t
  328. // | | | | | * | |
  329. // q
  330. // To require at most one NextAfter(), an error should be less than 1.5 * 2^-SB.
  331. // (8*P) * 2^-W + 2^-SB < 1.5 * 2^-SB
  332. // (8*P) * 2^-W < 0.5 * 2^-SB
  333. // P < 2^(W-4-SB)
  334. // Generally, for at most R NextAfter() to be enough,
  335. // P < (2*R - 1) * 2^(W-4-SB)
  336. // For f32 (0+3): 10 < 32 (OK)
  337. // For f32 (2+1): 32 < 74 < 32 * 3, so two NextAfter() are required
  338. // For f64: 220 < 256 (OK)
  339. // For f128: 4096 * 3 < 13922 < 4096 * 5 (three NextAfter() are required)
  340. // If we have overflowed the exponent, return infinity
  341. if (writtenExponent >= maxExponent)
  342. return fromRep(infRep | quotientSign);
  343. // Now, quotient_UQ1_SB <= the correctly-rounded result
  344. // and may need taking NextAfter() up to 3 times (see error estimates above)
  345. // r = a - b * q
  346. rep_t absResult;
  347. if (writtenExponent > 0) {
  348. // Clear the implicit bit
  349. absResult = quotient_UQ1 & significandMask;
  350. // Insert the exponent
  351. absResult |= (rep_t)writtenExponent << significandBits;
  352. residualLo <<= 1;
  353. } else {
  354. // Prevent shift amount from being negative
  355. if (significandBits + writtenExponent < 0)
  356. return fromRep(quotientSign);
  357. absResult = quotient_UQ1 >> (-writtenExponent + 1);
  358. // multiplied by two to prevent shift amount to be negative
  359. residualLo = (aSignificand << (significandBits + writtenExponent)) - (absResult * bSignificand << 1);
  360. }
  361. // Round
  362. residualLo += absResult & 1; // tie to even
  363. // The above line conditionally turns the below LT comparison into LTE
  364. absResult += residualLo > bSignificand;
  365. #if defined(QUAD_PRECISION) || (defined(SINGLE_PRECISION) && NUMBER_OF_HALF_ITERATIONS > 0)
  366. // Do not round Infinity to NaN
  367. absResult += absResult < infRep && residualLo > (2 + 1) * bSignificand;
  368. #endif
  369. #if defined(QUAD_PRECISION)
  370. absResult += absResult < infRep && residualLo > (4 + 1) * bSignificand;
  371. #endif
  372. return fromRep(absResult | quotientSign);
  373. }