Author: aandrejevic Date: Sat Jan 3 03:52:50 2015 New Revision: 65946
URL: http://svn.reactos.org/svn/reactos?rev=65946&view=rev Log: [FAST486] Fix a bug in UnsignedDivMod128.
Modified: trunk/reactos/lib/fast486/fpu.c
Modified: trunk/reactos/lib/fast486/fpu.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fpu.c?rev=65946... ============================================================================== --- trunk/reactos/lib/fast486/fpu.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/fpu.c [iso-8859-1] Sat Jan 3 03:52:50 2015 @@ -84,12 +84,14 @@ /* Initialize the quotient */ *QuotientLow = *QuotientHigh = 0ULL;
+ /* Exit early if the dividend is lower than the divisor */ + if ((DividendHigh == 0ULL) && (DividendLow < Divisor)) return ValueLow; + /* Normalize the current divisor */ Bits = CountLeadingZeros64(CurrentHigh); CurrentHigh <<= Bits;
- /* Loop while the value is higher than or equal to the original divisor */ - while ((ValueHigh > 0ULL) || (ValueLow >= Divisor)) + while (TRUE) { /* Shift the quotient left by one bit */ *QuotientHigh <<= 1; @@ -109,6 +111,9 @@
/* Set the lowest bit of the quotient */ *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 */