It should probably be + Exp -= (1 - EXCESS); in EFtoF() and + Exp += (1 - EXCESS); in FtoEF(). The other way round.
Suggestion to make it a little clearer: #define BIAS 127 Exp -+= (BIAS - 2);
jimtabor wrote:
--- trunk/reactos/dll/win32/gdi32/objects/painting.c 2006/12/28 22:36:53 25235 +++ trunk/reactos/dll/win32/gdi32/objects/painting.c 2007/05/14 03:18:42 26772 @@ -1,15 +1,66 @@
[...]
+/* the following deal with IEEE single-precision numbers */ +#define EXCESS 126L +#define SIGNBIT 0x80000000L +#define SIGN(fp) ((fp) & SIGNBIT) +#define EXP(fp) (((fp) >> 23L) & 0xFF) +#define MANT(fp) ((fp) & 0x7FFFFFL) +#define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
[...]
+LONG +FASTCALL +EFtoF( EFLOAT_S * efp) +{
- long Mant, Exp, Sign = 0;
- if (!efp->lMant) return 0;
- Mant = efp->lMant;
- Exp = efp->lExp;
- Sign = SIGN(Mant);
+//// M$ storage emulation
- Mant = ((Mant & 0x3fffffff) >> 7);
- Exp += (1 - EXCESS);
+////
- Mant = MANT(Mant);
- return PACK(Sign, Exp, Mant);
+}
+VOID +FASTCALL +FtoEF( EFLOAT_S * efp, FLOATL f) +{
- long Mant, Exp;
- gxf_long worker;
+#ifdef _X86_
- worker.l = f; // It's a float stored in a long.
+#else
- worker.f = f;
+#endif
- Exp = EXP(worker.l);
- Mant = MANT(worker.l);
+//// M$ storage emulation
- Mant = ((Mant << 7) | 0x40000000 | SIGN(worker.l));
- Exp -= (1 - EXCESS);
+////
- efp->lMant = Mant;
- efp->lExp = Exp;
+}