Author: aandrejevic Date: Fri May 22 04:51:20 2015 New Revision: 67846
URL: http://svn.reactos.org/svn/reactos?rev=67846&view=rev Log: [FAST486] Fix Fast486FpuToInteger.
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=67846... ============================================================================== --- trunk/reactos/lib/fast486/fpu.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/fpu.c [iso-8859-1] Fri May 22 04:51:20 2015 @@ -310,8 +310,7 @@ return TRUE; }
- if (FPU_IS_NAN(Value) || !FPU_IS_NORMALIZED(Value) - || (UnbiasedExp < 0) || (UnbiasedExp > 63)) + if (FPU_IS_NAN(Value) || !FPU_IS_NORMALIZED(Value) || (UnbiasedExp >= 63)) { /* Raise an invalid operation exception */ State->FpuStatus.Ie = TRUE; @@ -328,11 +327,31 @@ } }
- Bits = 63 - UnbiasedExp; - - /* Calculate the result and the remainder */ - *Result = (LONGLONG)(Value->Mantissa >> Bits); - Remainder = Value->Mantissa & ((1 << Bits) - 1); + if (UnbiasedExp >= 0) + { + Bits = 63 - UnbiasedExp; + + /* Calculate the result and the remainder */ + *Result = (LONGLONG)(Value->Mantissa >> Bits); + Remainder = Value->Mantissa & ((1 << Bits) - 1); + } + else + { + /* The result is zero */ + *Result = 0LL; + + if (UnbiasedExp > -64) + { + Bits = 65 + UnbiasedExp; + Remainder = Value->Mantissa >> (64 - Bits); + } + else + { + /* Too small to even have a remainder */ + Bits = 1; + Remainder = 0ULL; + } + }
/* The result must be positive here */ ASSERT(*Result >= 0LL);