ReactOS 0.4.15-dev-8100-g1887773
__64tof.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  _FLOAT_RESULT
 

Macros

#define FRACTION_LEN   23
 
#define EXPONENT_LEN   8
 
#define SHIFT_OFFSET   (EXPONENT_LEN + 32)
 
#define SIGN_MASK   0x8000000000000000ULL
 
#define EXPONENT_ZERO   ((1 << (EXPONENT_LEN - 1)) - 1)
 
#define NEGATE(x)   (~(x) + 1)
 

Typedefs

typedef float FLOAT_TYPE
 
typedef unsigned int FINT_TYPE
 
typedef unsigned long long INT64SU
 
typedef union _FLOAT_RESULT FLOAT_RESULT
 

Functions

FLOAT_TYPE __64tof (INT64SU value)
 

Macro Definition Documentation

◆ EXPONENT_LEN

#define EXPONENT_LEN   8

Definition at line 18 of file __64tof.h.

◆ EXPONENT_ZERO

#define EXPONENT_ZERO   ((1 << (EXPONENT_LEN - 1)) - 1)

Definition at line 36 of file __64tof.h.

◆ FRACTION_LEN

#define FRACTION_LEN   23

Definition at line 17 of file __64tof.h.

◆ NEGATE

#define NEGATE (   x)    (~(x) + 1)

Definition at line 38 of file __64tof.h.

◆ SHIFT_OFFSET

#define SHIFT_OFFSET   (EXPONENT_LEN + 32)

Definition at line 19 of file __64tof.h.

◆ SIGN_MASK

#define SIGN_MASK   0x8000000000000000ULL

Definition at line 34 of file __64tof.h.

Typedef Documentation

◆ FINT_TYPE

Definition at line 16 of file __64tof.h.

◆ FLOAT_RESULT

typedef union _FLOAT_RESULT FLOAT_RESULT

◆ FLOAT_TYPE

typedef float FLOAT_TYPE

Definition at line 15 of file __64tof.h.

◆ INT64SU

Definition at line 25 of file __64tof.h.

Function Documentation

◆ __64tof()

FLOAT_TYPE __64tof ( INT64SU  value)

Definition at line 41 of file __64tof.h.

42{
45 int count = 0;
46 unsigned long long mask = SIGN_MASK;
47
48 if (value == 0)
49 return (FLOAT_TYPE)0;
50
51#ifdef _USE_SIGNED_
52 if (value & SIGN_MASK)
53 {
55 /* set Sign bit using exponent */
56 exponent |= 1 << EXPONENT_LEN;
57 }
58#endif
59
60 for (; count < 64; count++)
61 {
62 if (value & mask)
63 break;
64 mask = mask >> 1;
65 }
66
68 /* exponent is FRACTION_LEN - count */
69 exponent -= count;
70 result.raw = exponent << FRACTION_LEN;
71
72 mask--;
73 value = value & mask;
74 if (value == 0)
75 return result.value;
76
77 if (count == 0)
78 {
79 result.raw |= value;
80 }
81 else if (count < 0)
82 {
83 count = NEGATE(count) - 1;
84 value = value >> count;
85 mask = value & 1;
86 result.raw |= value >> 1;
87
88 /* round up if left most bit of lost data is 1 */
89 if (mask)
90 result.raw++;
91 }
92 else
93 {
94 result.raw |= value << count;
95 }
96
97 return result.value;
98}
#define NEGATE(x)
Definition: __64tof.h:38
#define EXPONENT_LEN
Definition: __64tof.h:18
unsigned int FINT_TYPE
Definition: __64tof.h:16
#define SHIFT_OFFSET
Definition: __64tof.h:19
#define FRACTION_LEN
Definition: __64tof.h:17
#define SIGN_MASK
Definition: __64tof.h:34
#define EXPONENT_ZERO
Definition: __64tof.h:36
float FLOAT_TYPE
Definition: __64tof.h:15
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLint GLuint mask
Definition: glext.h:6028
GLuint64EXT * result
Definition: glext.h:11304
Definition: pdh_main.c:94