ReactOS 0.4.16-dev-87-g3dfbe52
floatobj.h
Go to the documentation of this file.
1#pragma once
2
3C_ASSERT(sizeof(FIX) == sizeof(LONG));
4#define FIX2LONG(x) (((x) + 8) >> 4)
5#define LONG2FIX(x) ((x) << 4)
6
7#if defined(_M_IX86)
8
10BOOL
11_FLOATOBJ_Equal(FLOATOBJ *pf1, FLOATOBJ *pf2)
12{
13 EFLOAT_S *pef1 = (EFLOAT_S*)pf1;
14 EFLOAT_S *pef2 = (EFLOAT_S*)pf2;
15 return (pef1->lMant == pef2->lMant && pef1->lExp == pef2->lExp);
16}
17#define FLOATOBJ_Equal _FLOATOBJ_Equal
18
30BOOL
32{
33 EFLOAT_S *pef = (EFLOAT_S*)pf;
34
35 if (pef->lExp > 32)
36 {
37 return FALSE;
38 }
39
40 if (pef->lExp < 2)
41 {
42 *pl = 0;
43 return TRUE;
44 }
45
46 *pl = EngMulDiv(pef->lMant, 1 << (pef->lExp - 2), 0x40000000);
47 return TRUE;
48}
49
51LONG
53{
54 EFLOAT_S *pef = (EFLOAT_S*)pf;
55 LONG Shift = (28 - pef->lExp);
56 return (Shift >= 0 ? pef->lMant >> Shift : pef->lMant << -Shift);
57}
58
60BOOL
62{
63 EFLOAT_S *pef = (EFLOAT_S*)pf;
64 ULONG ulShift = pef->lExp;
65 if (ulShift < 32)
66 return ((pef->lMant << ulShift) == 0);
67 else
68 return (ulShift == 32);
69}
70
72BOOL
74{
75 EFLOAT_S *pef = (EFLOAT_S*)pf;
76 return (pef->lMant == 0 && pef->lExp == 0);
77}
78
80BOOL
82{
83 EFLOAT_S *pef = (EFLOAT_S*)pf;
84 return (pef->lMant == 0x40000000 && pef->lExp == 2);
85}
86
87extern const FLOATOBJ gef0;
88extern const FLOATOBJ gef1;
89extern const FLOATOBJ gef2;
90extern const FLOATOBJ gef16;
91
92#define FLOATOBJ_0 {0x00000000, 0x00000000}
93#define FLOATOBJ_1 {0x40000000, 0x00000002}
94#define FLOATOBJ_16 {0x40000000, 0x00000006}
95#define FLOATOBJ_1_16 {0x40000000, 0xfffffffe}
96
97#define FLOATOBJ_Set0(fo) do { (fo)->ul1 = 0; (fo)->ul2 = 0; } while (0)
98#define FLOATOBJ_Set1(fo) do { (fo)->ul1 = 0x40000000; (fo)->ul2 = 2; } while (0)
99
100#else
101
102#define FLOATOBJ_bConvertToLong(pf, pl) (*pl = (LONG)*pf, TRUE)
103#define FLOATOBJ_IsLong(pf) ((FLOAT)((LONG)*(pf)) == *(pf))
104#define FLOATOBJ_Equal0(pf) (*(pf) == 0.)
105#define FLOATOBJ_Equal1(pf) (*(pf) == 1.)
106#define FLOATOBJ_GetFix(pf) ((LONG)(*(pf) * 16.))
107
108#define FLOATOBJ_0 0.
109#define FLOATOBJ_1 1.
110#define FLOATOBJ_16 16.
111#define FLOATOBJ_1_16 (1./16.)
112
113static const FLOATOBJ gef0 = 0.;
114static const FLOATOBJ gef1 = 1.;
115static const FLOATOBJ gef2 = 2.;
116static const FLOATOBJ gef16 = 16.;
117
118#define FLOATOBJ_Set0(fo) *(fo) = 0;
119#define FLOATOBJ_Set1(fo) *(fo) = 1;
120
121#endif
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLOATOBJ_IsLong(pf)
Definition: floatobj.h:103
#define FLOATOBJ_Equal0(pf)
Definition: floatobj.h:104
static const FLOATOBJ gef16
Definition: floatobj.h:116
static const FLOATOBJ gef1
Definition: floatobj.h:114
static const FLOATOBJ gef0
Definition: floatobj.h:113
static const FLOATOBJ gef2
Definition: floatobj.h:115
#define FLOATOBJ_GetFix(pf)
Definition: floatobj.h:106
#define FLOATOBJ_Equal1(pf)
Definition: floatobj.h:105
#define FLOATOBJ_bConvertToLong(pf, pl)
Definition: floatobj.h:102
#define C_ASSERT(e)
Definition: intsafe.h:73
long LONG
Definition: pedump.c:60
LONG lExp
Definition: ntgdityp.h:393
LONG lMant
Definition: ntgdityp.h:392
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define FORCEINLINE
Definition: wdftypes.h:67
FLOAT FLOATOBJ
Definition: winddi.h:677
ENGAPI INT APIENTRY EngMulDiv(_In_ INT a, _In_ INT b, _In_ INT c)
Definition: math.c:26
LONG FIX
Definition: winddi.h:126
_In_ ULONG Shift
Definition: rtlfuncs.h:2695