From 9f2630ccceb3544ebacc81253b8ad88595e2ba49 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Thu, 24 May 2007 01:39:31 +0000 Subject: [PATCH] - Fixed arithmetic semantics. Making it more Windows compatible. - This example work now. double F2F(PFLOATOBJ f) { if(SIGN(f->ul1)) // negate mant return (double) -(-f->ul1 * pow(2,(double)f->ul2-32)); else return (double) f->ul1 * pow(2,(double)f->ul2-32); } svn path=/trunk/; revision=26877 --- reactos/dll/win32/gdi32/objects/painting.c | 13 ++++++++----- reactos/subsystems/win32/win32k/eng/float.c | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/painting.c b/reactos/dll/win32/gdi32/objects/painting.c index 66bb6135ef6..dfae1da10db 100644 --- a/reactos/dll/win32/gdi32/objects/painting.c +++ b/reactos/dll/win32/gdi32/objects/painting.c @@ -31,8 +31,9 @@ EFtoF( EFLOAT_S * efp) Sign = SIGN(Mant); //// M$ storage emulation + if( Sign ) Mant = -Mant; Mant = ((Mant & 0x3fffffff) >> 7); - Exp += (1 - EXCESS); + Exp += (EXCESS-1); //// Mant = MANT(Mant); return PACK(Sign, Exp, Mant); @@ -42,7 +43,7 @@ VOID FASTCALL FtoEF( EFLOAT_S * efp, FLOATL f) { - long Mant, Exp; + long Mant, Exp, Sign = 0; gxf_long worker; #ifdef _X86_ @@ -53,10 +54,12 @@ FtoEF( EFLOAT_S * efp, FLOATL f) Exp = EXP(worker.l); Mant = MANT(worker.l); - + if (SIGN(worker.l)) Sign = -1; //// M$ storage emulation - Mant = ((Mant << 7) | 0x40000000 | SIGN(worker.l)); - Exp -= (1 - EXCESS); + Mant = ((Mant << 7) | 0x40000000); + Mant ^= Sign; + Mant -= Sign; + Exp -= (EXCESS-1); //// efp->lMant = Mant; efp->lExp = Exp; diff --git a/reactos/subsystems/win32/win32k/eng/float.c b/reactos/subsystems/win32/win32k/eng/float.c index 21537491954..ed19b775ebe 100644 --- a/reactos/subsystems/win32/win32k/eng/float.c +++ b/reactos/subsystems/win32/win32k/eng/float.c @@ -101,9 +101,7 @@ VOID FASTCALL EF_Negate(EFLOAT_S * efp) { -// Do it this way since ReactOS uses real FP. - if (SIGN(efp->lMant)) efp->lMant = efp->lMant & ~SIGNBIT; - else efp->lMant = efp->lMant | SIGNBIT; + efp->lMant = -efp->lMant; } LONG @@ -119,8 +117,9 @@ EFtoF( EFLOAT_S * efp) Sign = SIGN(Mant); //// M$ storage emulation - Mant = ((Mant & 0x3fffffff)>>7); - Exp += (1 - EXCESS); + if( Sign ) Mant = -Mant; + Mant = ((Mant & 0x3fffffff) >> 7); + Exp += (EXCESS-1); //// Mant = MANT(Mant); return PACK(Sign, Exp, Mant); @@ -130,7 +129,7 @@ VOID FASTCALL FtoEF( EFLOAT_S * efp, FLOATL f) { - long Mant, Exp; + long Mant, Exp, Sign = 0; gxf_long worker; #ifdef _X86_ @@ -141,10 +140,12 @@ FtoEF( EFLOAT_S * efp, FLOATL f) Exp = EXP(worker.l); Mant = MANT(worker.l); - + if (SIGN(worker.l)) Sign = -1; //// M$ storage emulation - Mant = ((Mant << 7) | 0x40000000 | SIGN(worker.l)); - Exp -= (1 - EXCESS); + Mant = ((Mant << 7) | 0x40000000); + Mant ^= Sign; + Mant -= Sign; + Exp -= (EXCESS-1); //// efp->lMant = Mant; efp->lExp = Exp;