Lines Matching refs:pDivisor

2114  * @param   pDivisor        What to divide by.
2116 static int rtBigNumMagnitudeDivideKnuth(PRTBIGNUM pQuotient, PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor)
2118 Assert(pDivisor->cUsed > 1);
2119 uint32_t const cDivisor = pDivisor->cUsed;
2146 uint32_t cNormShift = (RTBIGNUM_ELEMENT_BITS - rtBigNumMagnitudeBitWidth(pDivisor)) & (RTBIGNUM_ELEMENT_BITS - 1);
2152 rc = rtBigNumMagnitudeShiftLeft(&NormDivisor, pDivisor, cNormShift);
2156 pNormDivisor = pDivisor;
2222 if (pDivisor == &NormDivisor)
2228 static int rtBigNumMagnitudeDivideSlowLong(PRTBIGNUM pQuotient, PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor)
2239 int iDiff = rtBigNumMagnitudeCompare(pRemainder, pDivisor);
2244 rc = rtBigNumMagnitudeSubThis(pRemainder, pDivisor);
2273 * @param pDivisor What to divide by.
2276 static int rtBigNumMagnitudeDivide(PRTBIGNUM pQuotient, PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor,
2279 Assert(pQuotient != pDividend); Assert(pQuotient != pDivisor); Assert(pRemainder != pDividend); Assert(pRemainder != pDivisor); Assert(pRemainder != pQuotient);
2280 Assert(!pQuotient->fCurScrambled); Assert(!pRemainder->fCurScrambled); Assert(!pDividend->fCurScrambled); Assert(!pDivisor->fCurScrambled);
2293 if (!pDivisor->cUsed || !pDividend->cUsed)
2294 return pDivisor->cUsed ? VINF_SUCCESS : VERR_BIGNUM_DIV_BY_ZERO;
2299 if (pDivisor->cUsed == 1 && pDivisor->pauElements[0] == 1)
2305 int iDiff = rtBigNumMagnitudeCompare(pDividend, pDivisor);
2332 RTBIGNUMELEMENT uQ = pDividend->pauElements[0] / pDivisor->pauElements[0];
2333 RTBIGNUMELEMENT uR = pDividend->pauElements[0] % pDivisor->pauElements[0];
2354 if (pDivisor->cUsed == 1)
2357 pDivisor->pauElements[0]);
2362 pDivisor->pauElements[1], pDivisor->pauElements[0]);
2372 else if (pDivisor->cUsed < 2 || fForceLong)
2373 rc = rtBigNumMagnitudeDivideSlowLong(pQuotient, pRemainder, pDividend, pDivisor);
2375 rc = rtBigNumMagnitudeDivideKnuth(pQuotient, pRemainder, pDividend, pDivisor);
2381 PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor, bool fForceLong)
2383 Assert(pQuotient != pDividend); Assert(pQuotient != pDivisor); Assert(pRemainder != pDividend); Assert(pRemainder != pDivisor); Assert(pRemainder != pQuotient);
2384 AssertReturn(pQuotient->fSensitive >= (pDividend->fSensitive | pDivisor->fSensitive), VERR_BIGNUM_SENSITIVE_INPUT);
2385 AssertReturn(pRemainder->fSensitive >= (pDividend->fSensitive | pDivisor->fSensitive), VERR_BIGNUM_SENSITIVE_INPUT);
2399 rc = rtBigNumUnscramble((PRTBIGNUM)pDivisor);
2402 RTBIGNUM_ASSERT_VALID(pDivisor);
2412 pQuotient->fNegative = pDividend->fNegative ^ pDivisor->fNegative;
2415 rc = rtBigNumMagnitudeDivide(pQuotient, pRemainder, pDividend, pDivisor, fForceLong);
2422 rtBigNumScramble((PRTBIGNUM)pDivisor);
2434 RTDECL(int) RTBigNumDivide(PRTBIGNUM pQuotient, PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor)
2436 return rtBigNumDivideCommon(pQuotient, pRemainder, pDividend, pDivisor, false /*fForceLong*/);
2440 RTDECL(int) RTBigNumDivideLong(PRTBIGNUM pQuotient, PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor)
2442 return rtBigNumDivideCommon(pQuotient, pRemainder, pDividend, pDivisor, true /*fForceLong*/);
2456 * @param pDivisor What to divide by.
2458 static int rtBigNumMagnitudeModulo(PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor)
2460 Assert(pRemainder != pDividend); Assert(pRemainder != pDivisor);
2461 Assert(!pRemainder->fCurScrambled); Assert(!pDividend->fCurScrambled); Assert(!pDivisor->fCurScrambled);
2473 if (!pDivisor->cUsed || !pDividend->cUsed)
2474 return pDivisor->cUsed ? VINF_SUCCESS : VERR_BIGNUM_DIV_BY_ZERO;
2479 if (pDivisor->cUsed == 1 && pDivisor->pauElements[0] == 1)
2485 int iDiff = rtBigNumMagnitudeCompare(pDividend, pDivisor);
2498 if (pDivisor->cUsed < 2)
2508 iDiff = rtBigNumMagnitudeCompare(pRemainder, pDivisor);
2513 rc = rtBigNumMagnitudeSubThis(pRemainder, pDivisor);
2526 rc = rtBigNumMagnitudeDivideKnuth(NULL, pRemainder, pDividend, pDivisor);
2535 RTDECL(int) RTBigNumModulo(PRTBIGNUM pRemainder, PCRTBIGNUM pDividend, PCRTBIGNUM pDivisor)
2537 Assert(pRemainder != pDividend); Assert(pRemainder != pDivisor);
2538 AssertReturn(pRemainder->fSensitive >= (pDividend->fSensitive | pDivisor->fSensitive), VERR_BIGNUM_SENSITIVE_INPUT);
2548 rc = rtBigNumUnscramble((PRTBIGNUM)pDivisor);
2551 RTBIGNUM_ASSERT_VALID(pDivisor);
2558 rc = rtBigNumMagnitudeModulo(pRemainder, pDividend, pDivisor);
2563 rtBigNumScramble((PRTBIGNUM)pDivisor);