ReactOS 0.4.16-dev-2104-gb84fa49
bnum.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bnum
 

Macros

#define EXP_BITS   11
 
#define MANT_BITS   53
 
#define LIMB_DIGITS   9 /* each DWORD stores up to 9 digits */
 
#define LIMB_MAX   1000000000 /* 10^9 */
 
#define BNUM_PREC64   128 /* data size needed to store 64-bit double */
 
#define BNUM_PREC80   2048 /* data size needed to store 80-bit double */
 

Functions

static int bnum_idx (struct bnum *b, int idx)
 
static BOOL bnum_lshift (struct bnum *b, int shift)
 
static BOOL bnum_rshift (struct bnum *b, int shift)
 
static void bnum_mult (struct bnum *b, int mult)
 

Variables

static const int p10s [] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }
 

Macro Definition Documentation

◆ BNUM_PREC64

#define BNUM_PREC64   128 /* data size needed to store 64-bit double */

Definition at line 30 of file bnum.h.

◆ BNUM_PREC80

#define BNUM_PREC80   2048 /* data size needed to store 80-bit double */

Definition at line 31 of file bnum.h.

◆ EXP_BITS

#define EXP_BITS   11

Definition at line 22 of file bnum.h.

◆ LIMB_DIGITS

#define LIMB_DIGITS   9 /* each DWORD stores up to 9 digits */

Definition at line 27 of file bnum.h.

◆ LIMB_MAX

#define LIMB_MAX   1000000000 /* 10^9 */

Definition at line 28 of file bnum.h.

◆ MANT_BITS

#define MANT_BITS   53

Definition at line 23 of file bnum.h.

Function Documentation

◆ bnum_idx()

static int bnum_idx ( struct bnum b,
int  idx 
)
inlinestatic

Definition at line 41 of file bnum.h.

42{
43 return idx & (b->size - 1);
44}
unsigned int idx
Definition: utils.c:41
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

Referenced by bnum_lshift(), bnum_mult(), bnum_rshift(), bnum_to_mant(), fpnum_parse_bnum(), and pf_output_fp().

◆ bnum_lshift()

static BOOL bnum_lshift ( struct bnum b,
int  shift 
)
inlinestatic

Definition at line 47 of file bnum.h.

48{
49 DWORD rest = 0;
50 ULONGLONG tmp;
51 int i;
52
53 /* The limbs number can change by up to 1 so shift <= 29 */
54 assert(shift <= 29);
55
56 for(i=b->b; i<b->e; i++) {
57 tmp = ((ULONGLONG)b->data[bnum_idx(b, i)] << shift) + rest;
58 rest = tmp / LIMB_MAX;
59 b->data[bnum_idx(b, i)] = tmp % LIMB_MAX;
60
61 if(i == b->b && !b->data[bnum_idx(b, i)])
62 b->b++;
63 }
64
65 if(rest) {
66 b->data[bnum_idx(b, b->e)] = rest;
67 b->e++;
68
69 if(bnum_idx(b, b->b) == bnum_idx(b, b->e)) {
70 if(b->data[bnum_idx(b, b->b)]) b->data[bnum_idx(b, b->b+1)] |= 1;
71 b->b++;
72 }
73 return TRUE;
74 }
75 return FALSE;
76}
#define LIMB_MAX
Definition: bnum.h:28
static int bnum_idx(struct bnum *b, int idx)
Definition: bnum.h:41
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define assert(_expr)
Definition: assert.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define e
Definition: ke_i.h:82
#define shift
Definition: input.c:1755
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by fpnum_parse_bnum(), and pf_output_fp().

◆ bnum_mult()

static void bnum_mult ( struct bnum b,
int  mult 
)
inlinestatic

Definition at line 109 of file bnum.h.

110{
111 DWORD rest = 0;
112 ULONGLONG tmp;
113 int i;
114
115 assert(mult <= LIMB_MAX);
116
117 for(i=b->b; i<b->e; i++) {
118 tmp = ((ULONGLONG)b->data[bnum_idx(b, i)] * mult) + rest;
119 rest = tmp / LIMB_MAX;
120 b->data[bnum_idx(b, i)] = tmp % LIMB_MAX;
121
122 if(i == b->b && !b->data[bnum_idx(b, i)])
123 b->b++;
124 }
125
126 if(rest) {
127 b->data[bnum_idx(b, b->e)] = rest;
128 b->e++;
129
130 if(bnum_idx(b, b->b) == bnum_idx(b, b->e)) {
131 if(b->data[bnum_idx(b, b->b)]) b->data[bnum_idx(b, b->b+1)] |= 1;
132 b->b++;
133 }
134 }
135}

Referenced by fpnum_parse_bnum().

◆ bnum_rshift()

static BOOL bnum_rshift ( struct bnum b,
int  shift 
)
inlinestatic

Definition at line 79 of file bnum.h.

80{
81 DWORD tmp, rest = 0;
82 BOOL ret = FALSE;
83 int i;
84
85 /* Compute LIMB_MAX << shift without accuracy loss */
86 assert(shift <= 9);
87
88 for(i=b->e-1; i>=b->b; i--) {
89 tmp = b->data[bnum_idx(b, i)] & ((1<<shift)-1);
90 b->data[bnum_idx(b, i)] = (b->data[bnum_idx(b, i)] >> shift) + rest;
91 rest = (LIMB_MAX >> shift) * tmp;
92 if(i==b->e-1 && !b->data[bnum_idx(b, i)]) {
93 b->e--;
94 ret = TRUE;
95 }
96 }
97
98 if(rest) {
99 if(bnum_idx(b, b->b-1) == bnum_idx(b, b->e)) {
100 if(rest) b->data[bnum_idx(b, b->b)] |= 1;
101 } else {
102 b->b--;
103 b->data[bnum_idx(b, b->b)] = rest;
104 }
105 }
106 return ret;
107}
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by fpnum_parse_bnum(), and pf_output_fp().

Variable Documentation

◆ p10s

const int p10s[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }
static

Definition at line 25 of file bnum.h.

Referenced by fpnum_parse_bnum(), log10i(), and pf_output_fp().