mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 16:52:15 +00:00
[FAST486]
Fix UnsignedDivMod128 (again). Fix Fast486FpuAdd to handle numbers whose difference of exponents is greater than the number of bits in the mantissa. svn path=/trunk/; revision=67827
This commit is contained in:
parent
3bdb6b6e45
commit
94d8c8c4b2
1 changed files with 30 additions and 5 deletions
|
@ -204,9 +204,16 @@ UnsignedDivMod128(ULONGLONG DividendLow,
|
||||||
* divisor has more than the original divisor
|
* divisor has more than the original divisor
|
||||||
*/
|
*/
|
||||||
Bits = CountLeadingZeros64(Divisor);
|
Bits = CountLeadingZeros64(Divisor);
|
||||||
if (CurrentHigh > 0ULL) Bits -= CountLeadingZeros64(CurrentHigh);
|
if (CurrentHigh > 0ULL) Bits += 64 - CountLeadingZeros64(CurrentHigh);
|
||||||
else Bits -= CountLeadingZeros64(CurrentLow);
|
else Bits -= CountLeadingZeros64(CurrentLow);
|
||||||
|
|
||||||
|
if (Bits >= 64)
|
||||||
|
{
|
||||||
|
*QuotientHigh = *QuotientLow;
|
||||||
|
*QuotientLow = 0ULL;
|
||||||
|
Bits -= 64;
|
||||||
|
}
|
||||||
|
|
||||||
if (Bits)
|
if (Bits)
|
||||||
{
|
{
|
||||||
/* Shift the quotient left by that amount */
|
/* Shift the quotient left by that amount */
|
||||||
|
@ -635,15 +642,33 @@ Fast486FpuAdd(PFAST486_STATE State,
|
||||||
/* Adjust the first operand to it... */
|
/* Adjust the first operand to it... */
|
||||||
if (FirstAdjusted.Exponent < TempResult.Exponent)
|
if (FirstAdjusted.Exponent < TempResult.Exponent)
|
||||||
{
|
{
|
||||||
FirstAdjusted.Mantissa >>= (TempResult.Exponent - FirstAdjusted.Exponent);
|
if ((TempResult.Exponent - FirstAdjusted.Exponent) < 64)
|
||||||
FirstAdjusted.Exponent = TempResult.Exponent;
|
{
|
||||||
|
FirstAdjusted.Mantissa >>= (TempResult.Exponent - FirstAdjusted.Exponent);
|
||||||
|
FirstAdjusted.Exponent = TempResult.Exponent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The second operand is the result */
|
||||||
|
*Result = *SecondOperand;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ... and the second one too */
|
/* ... and the second one too */
|
||||||
if (SecondAdjusted.Exponent < TempResult.Exponent)
|
if (SecondAdjusted.Exponent < TempResult.Exponent)
|
||||||
{
|
{
|
||||||
SecondAdjusted.Mantissa >>= (TempResult.Exponent - SecondAdjusted.Exponent);
|
if ((TempResult.Exponent - FirstAdjusted.Exponent) < 64)
|
||||||
SecondAdjusted.Exponent = TempResult.Exponent;
|
{
|
||||||
|
SecondAdjusted.Mantissa >>= (TempResult.Exponent - SecondAdjusted.Exponent);
|
||||||
|
SecondAdjusted.Exponent = TempResult.Exponent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The first operand is the result */
|
||||||
|
*Result = *FirstOperand;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FirstAdjusted.Sign == SecondAdjusted.Sign)
|
if (FirstAdjusted.Sign == SecondAdjusted.Sign)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue