mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:53:06 +00:00
[FAST486]
Fix a bug in UnsignedDivMod128. svn path=/trunk/; revision=65946
This commit is contained in:
parent
d8f89bc80c
commit
f122f72179
1 changed files with 7 additions and 2 deletions
|
@ -84,12 +84,14 @@ UnsignedDivMod128(ULONGLONG DividendLow,
|
||||||
/* Initialize the quotient */
|
/* Initialize the quotient */
|
||||||
*QuotientLow = *QuotientHigh = 0ULL;
|
*QuotientLow = *QuotientHigh = 0ULL;
|
||||||
|
|
||||||
|
/* Exit early if the dividend is lower than the divisor */
|
||||||
|
if ((DividendHigh == 0ULL) && (DividendLow < Divisor)) return ValueLow;
|
||||||
|
|
||||||
/* Normalize the current divisor */
|
/* Normalize the current divisor */
|
||||||
Bits = CountLeadingZeros64(CurrentHigh);
|
Bits = CountLeadingZeros64(CurrentHigh);
|
||||||
CurrentHigh <<= Bits;
|
CurrentHigh <<= Bits;
|
||||||
|
|
||||||
/* Loop while the value is higher than or equal to the original divisor */
|
while (TRUE)
|
||||||
while ((ValueHigh > 0ULL) || (ValueLow >= Divisor))
|
|
||||||
{
|
{
|
||||||
/* Shift the quotient left by one bit */
|
/* Shift the quotient left by one bit */
|
||||||
*QuotientHigh <<= 1;
|
*QuotientHigh <<= 1;
|
||||||
|
@ -109,6 +111,9 @@ UnsignedDivMod128(ULONGLONG DividendLow,
|
||||||
|
|
||||||
/* Set the lowest bit of the quotient */
|
/* Set the lowest bit of the quotient */
|
||||||
*QuotientLow |= 1;
|
*QuotientLow |= 1;
|
||||||
|
|
||||||
|
/* Stop if the value is lower than the original divisor */
|
||||||
|
if ((ValueHigh == 0ULL) && (ValueLow < Divisor)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shift the current divisor right by one bit */
|
/* Shift the current divisor right by one bit */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue