- Fixed arithmetic semantics. Making it more Windows compatible.
authorJames Tabor <james.tabor@reactos.org>
Thu, 24 May 2007 01:39:31 +0000 (01:39 +0000)
committerJames Tabor <james.tabor@reactos.org>
Thu, 24 May 2007 01:39:31 +0000 (01:39 +0000)
- 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
reactos/subsystems/win32/win32k/eng/float.c

index 66bb613..dfae1da 100644 (file)
@@ -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;
index 2153749..ed19b77 100644 (file)
@@ -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;