ReactOS 0.4.16-dev-329-g9223134
efloat.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS System Libraries
4 * FILE: win32ss/gdi/gdi32/objects/efloat.c
5 * PURPOSE: Functions to convert between FLOAT and EFLOAT
6 * PROGRAMMER: James Tabor
7 */
8#include <precomp.h>
9
10/* the following deal with IEEE single-precision numbers */
11#define EXCESS 126L
12#define SIGNBIT 0x80000000L
13#define SIGN(fp) ((fp) & SIGNBIT)
14#define EXP(fp) (((fp) >> 23L) & 0xFF)
15#define MANT(fp) ((fp) & 0x7FFFFFL)
16#define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
17
21{
22 ULONG Mant, Exp, Sign;
23
24 if (!efp->lMant) return 0;
25
26 Mant = efp->lMant;
27 Exp = efp->lExp;
28 Sign = SIGN(Mant);
29
30 if (Sign) Mant = -(LONG)Mant;
31 Mant >>= 7;
32 Exp += (EXCESS-1);
33
34 Mant = MANT(Mant);
35 return PACK(Sign, Exp, Mant);
36}
37
38VOID
41{
42 ULONG Mant, Exp, Sign = 0;
43 gxf_long worker;
44
45#ifdef _X86_
46 worker.l = f; // It's a float stored in a long.
47#else
48 worker.f = f;
49#endif
50
51 Exp = EXP(worker.l);
52 Mant = MANT(worker.l);
53 if (SIGN(worker.l)) Sign = -1;
54
55 Mant = ((Mant << 7) | 0x40000000);
56 Mant ^= Sign;
57 Mant -= Sign;
58 Exp -= (EXCESS-1);
59
60 efp->lMant = Mant;
61 efp->lExp = Exp;
62}
@ Sign
Definition: msg.c:1064
#define SIGN(fp)
Definition: efloat.c:13
#define EXP(fp)
Definition: efloat.c:14
FLOATL FASTCALL EFtoF(EFLOAT_S *efp)
Definition: efloat.c:20
#define EXCESS
Definition: efloat.c:11
#define MANT(fp)
Definition: efloat.c:15
VOID FASTCALL FtoEF(EFLOAT_S *efp, FLOATL f)
Definition: efloat.c:40
#define PACK(s, e, m)
Definition: efloat.c:16
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
#define FASTCALL
Definition: nt_native.h:50
long LONG
Definition: pedump.c:60
LONG lExp
Definition: ntgdityp.h:393
LONG lMant
Definition: ntgdityp.h:392
uint32_t ULONG
Definition: typedefs.h:59
ULONG l
Definition: ntgdityp.h:427
FLOAT f
Definition: ntgdityp.h:426
FLOAT FLOATL
Definition: winddi.h:114