ReactOS  0.4.13-dev-544-gede3fdd
rpn_ieee.c File Reference
#include "calc.h"
Include dependency graph for rpn_ieee.c:

Go to the source code of this file.

Classes

struct  stack_node_t
 
struct  calc_operator_t
 

Typedefs

typedef void(* operator_call) (calc_number_t *, calc_number_t *, calc_number_t *)
 

Functions

static void rpn_add_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_sub_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_mul_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_div_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_mod_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_pow_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_sqr_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_and_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_or_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_xor_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_shl_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_shr_f (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_add_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_sub_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_mul_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_div_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_mod_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_and_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_or_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_xor_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_shl_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_shr_i (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_add_p (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_sub_p (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_mul_p (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static void rpn_div_p (calc_number_t *r, calc_number_t *a, calc_number_t *b)
 
static calc_node_tpop (void)
 
static int is_stack_empty (void)
 
static void push (calc_node_t *op)
 
void run_operator (calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
 
static void evalStack (calc_number_t *number)
 
int exec_infix2postfix (calc_number_t *number, unsigned int func)
 
void exec_change_infix (void)
 
void exec_closeparent (calc_number_t *number)
 
int eval_parent_count (void)
 
void flush_postfix (void)
 
void start_rpn_engine (void)
 
void stop_rpn_engine (void)
 

Variables

static stack_node_tstack
 
static calc_node_t temp
 
static BOOL percent_mode
 
static const calc_operator_t operator_list []
 

Typedef Documentation

◆ operator_call

typedef void(* operator_call) (calc_number_t *, calc_number_t *, calc_number_t *)

Definition at line 28 of file rpn_ieee.c.

Function Documentation

◆ eval_parent_count()

int eval_parent_count ( void  )

Definition at line 457 of file rpn_ieee.c.

458 {
459  stack_node_t *s = stack;
460  int n = 0;
461 
462  while (s != NULL) {
463  if (s->node.operation == RPN_OPERATOR_PARENT)
464  n++;
465  s = (stack_node_t *)(s->next);
466  }
467  return n;
468 }
GLdouble n
Definition: glext.h:7729
static stack_node_t * stack
Definition: rpn_ieee.c:37
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039

◆ evalStack()

static void evalStack ( calc_number_t number)
static

Definition at line 357 of file rpn_ieee.c.

358 {
359  calc_node_t *op, ip;
360  unsigned int prec;
361 
362  op = pop();
363  ip = *op;
364  prec = operator_list[ip.operation].prec;
365  while (!is_stack_empty()) {
366  op = pop();
367 
368  if (prec <= operator_list[op->operation].prec) {
369  if (op->operation == RPN_OPERATOR_PARENT) continue;
370 
371  calc.prev = ip.number;
372  run_operator(&ip, op, &ip, op->operation);
373  if (calc.is_nan) {
374  flush_postfix();
375  return;
376  }
377  } else {
378  push(op);
379  break;
380  }
381  }
382 
383  if (ip.operation != RPN_OPERATOR_EQUAL && ip.operation != RPN_OPERATOR_PERCENT)
384  push(&ip);
385 
386  calc.prev_operator = op->operation;
387 
388  *number = ip.number;
389 }
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
BOOL is_nan
Definition: calc.h:183
static size_t double number
Definition: printf.c:64
int ip[4]
Definition: rtl.c:1176
unsigned int prec
Definition: rpn_ieee.c:31
unsigned int prev_operator
Definition: calc.h:198
static const calc_operator_t operator_list[]
Definition: rpn_ieee.c:72
Definition: dhcpd.h:61
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn_ieee.c:314
static int is_stack_empty(void)
Definition: rpn_ieee.c:108
UINT op
Definition: effect.c:223
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
calc_t calc
Definition: winmain.c:247
void flush_postfix(void)
Definition: rpn_ieee.c:470
calc_number_t prev
Definition: calc.h:179

Referenced by exec_infix2postfix().

◆ exec_change_infix()

void exec_change_infix ( void  )

Definition at line 422 of file rpn_ieee.c.

423 {
424  stack_node_t *op = stack;
425 
426  if (op == NULL)
427  return;
428  if (op->node.operation == RPN_OPERATOR_PARENT ||
429  op->node.operation == RPN_OPERATOR_PERCENT ||
430  op->node.operation == RPN_OPERATOR_EQUAL)
431  return;
432  /* remove the head, it will be re-inserted with new operator */
433  pop();
434 }
static stack_node_t * stack
Definition: rpn_ieee.c:37
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
smooth NULL
Definition: ftsmooth.c:416
UINT op
Definition: effect.c:223

◆ exec_closeparent()

void exec_closeparent ( calc_number_t number)

Definition at line 436 of file rpn_ieee.c.

437 {
438  calc_node_t *op, ip;
439 
440  ip.number = *number;
441  ip.base = calc.base;
442  while (!is_stack_empty()) {
443  op = pop();
444 
445  if (op->operation == RPN_OPERATOR_PARENT)
446  break;
447 
448  run_operator(&ip, op, &ip, op->operation);
449  if (calc.is_nan) {
450  flush_postfix();
451  return;
452  }
453  }
454  *number = ip.number;
455 }
DWORD base
Definition: calc.h:189
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
BOOL is_nan
Definition: calc.h:183
static size_t double number
Definition: printf.c:64
int ip[4]
Definition: rtl.c:1176
Definition: dhcpd.h:61
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn_ieee.c:314
static int is_stack_empty(void)
Definition: rpn_ieee.c:108
UINT op
Definition: effect.c:223
calc_t calc
Definition: winmain.c:247
void flush_postfix(void)
Definition: rpn_ieee.c:470

◆ exec_infix2postfix()

int exec_infix2postfix ( calc_number_t number,
unsigned int  func 
)

Definition at line 391 of file rpn_ieee.c.

392 {
393  calc_node_t tmp;
394 
395  if (is_stack_empty() && func == RPN_OPERATOR_EQUAL) {
396  /* if a number has been entered with exponential */
397  /* notation, I may update it with normal mode */
398  if (calc.sci_in)
399  return 1;
400  return 0;
401  }
402 
403  if (func == RPN_OPERATOR_PERCENT)
404  percent_mode = TRUE;
405 
406  tmp.number = *number;
407  tmp.base = calc.base;
408  tmp.operation = func;
409 
410  push(&tmp);
411 
412  if (func == RPN_OPERATOR_NONE)
413  return 0;
414 
415  if (func != RPN_OPERATOR_PARENT) {
417  evalStack(number);
418  }
419  return 1;
420 }
static void evalStack(calc_number_t *number)
Definition: rpn_ieee.c:357
GLenum func
Definition: glext.h:6028
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
static size_t double number
Definition: printf.c:64
BOOL sci_in
Definition: calc.h:185
unsigned int last_operator
Definition: calc.h:197
calc_number_t number
Definition: calc.h:133
static int is_stack_empty(void)
Definition: rpn_ieee.c:108
DWORD base
Definition: calc.h:135
unsigned int operation
Definition: calc.h:134
static void push(calc_node_t *op)
Definition: rpn_ieee.c:113
calc_t calc
Definition: winmain.c:247
static BOOL percent_mode
Definition: rpn_ieee.c:39

◆ flush_postfix()

void flush_postfix ( void  )

Definition at line 470 of file rpn_ieee.c.

471 {
472  while (!is_stack_empty())
473  pop();
474  /* clear prev and last typed operators */
476  calc.last_operator = 0;
477 }
static calc_node_t * pop(void)
Definition: rpn_ieee.c:90
unsigned int prev_operator
Definition: calc.h:198
unsigned int last_operator
Definition: calc.h:197
static int is_stack_empty(void)
Definition: rpn_ieee.c:108
calc_t calc
Definition: winmain.c:247

Referenced by evalStack(), and exec_closeparent().

◆ is_stack_empty()

static int is_stack_empty ( void  )
static

Definition at line 108 of file rpn_ieee.c.

109 {
110  return (stack == NULL);
111 }
smooth NULL
Definition: ftsmooth.c:416
Definition: _stack.h:47

Referenced by evalStack(), exec_closeparent(), exec_infix2postfix(), and flush_postfix().

◆ pop()

static calc_node_t* pop ( void  )
static

Definition at line 90 of file rpn_ieee.c.

91 {
92  void *next;
93 
94  if (stack == NULL)
95  return NULL;
96 
97  /* copy the node */
98  temp = stack->node;
99  next = stack->next;
100 
101  /* free the node */
102  free(stack);
103  stack = next;
104 
105  return &temp;
106 }
#define free
Definition: debug_ros.c:5
smooth NULL
Definition: ftsmooth.c:416
Definition: _stack.h:47
static unsigned __int64 next
Definition: rand_nt.c:6
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by crc32(), evalStack(), exec_change_infix(), exec_closeparent(), flush_postfix(), MyAppendUnicodeToString_(), MyInitUnicodeString(), push_buffer(), RtlAppendUnicodeToString(), UDFCheckZeroBuf(), UDFCrc(), UDFDissectName(), UDFGetExtentLength(), UDFGetMappingLength(), UDFIsIllegalChar(), UDFPhysLbaToPart(), UDFUnicodeCksum(), UDFUnicodeCksum150(), and WCacheGetSortedListIndex().

◆ push()

◆ rpn_add_f()

static void rpn_add_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 132 of file rpn_ieee.c.

133 {
134  r->f = a->f + b->f;
135 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_add_i()

static void rpn_add_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 234 of file rpn_ieee.c.

235 {
236  r->i = a->i + b->i;
237 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_add_p()

static void rpn_add_p ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 291 of file rpn_ieee.c.

292 {
293  r->f = a->f * (1. + b->f/100.);
294 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_and_f()

static void rpn_and_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 167 of file rpn_ieee.c.

168 {
169  calc_number_t ai, bi;
170 
171  ai.i = logic_dbl2int(a);
172  bi.i = logic_dbl2int(b);
173 
174  r->f = (long double)(ai.i & bi.i);
175 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
INT64 i
Definition: calc.h:127
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_and_i()

static void rpn_and_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 265 of file rpn_ieee.c.

266 {
267  r->i = a->i & b->i;
268 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_div_f()

static void rpn_div_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 147 of file rpn_ieee.c.

148 {
149  if (b->f == 0)
150  calc.is_nan = TRUE;
151  else
152  r->f = a->f / b->f;
153 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL is_nan
Definition: calc.h:183
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

◆ rpn_div_i()

static void rpn_div_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 249 of file rpn_ieee.c.

250 {
251  if (b->i == 0)
252  calc.is_nan = TRUE;
253  else
254  r->i = a->i / b->i;
255 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL is_nan
Definition: calc.h:183
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

◆ rpn_div_p()

static void rpn_div_p ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 306 of file rpn_ieee.c.

307 {
308  if (b->f == 0)
309  calc.is_nan = TRUE;
310  else
311  r->f = a->f * 100. / b->f;
312 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL is_nan
Definition: calc.h:183
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

◆ rpn_mod_f()

static void rpn_mod_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 155 of file rpn_ieee.c.

156 {
157  double t;
158 
159  if (b->f == 0)
160  calc.is_nan = TRUE;
161  else {
162  modf(a->f/b->f, &t);
163  r->f = a->f - (t * b->f);
164  }
165 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
BOOL is_nan
Definition: calc.h:183
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_mod_i()

static void rpn_mod_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 257 of file rpn_ieee.c.

258 {
259  if (b->i == 0)
260  calc.is_nan = TRUE;
261  else
262  r->i = a->i % b->i;
263 }
#define TRUE
Definition: types.h:120
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL is_nan
Definition: calc.h:183
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

◆ rpn_mul_f()

static void rpn_mul_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 142 of file rpn_ieee.c.

143 {
144  r->f = a->f * b->f;
145 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_mul_i()

static void rpn_mul_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 244 of file rpn_ieee.c.

245 {
246  r->i = a->i * b->i;
247 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_mul_p()

static void rpn_mul_p ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 301 of file rpn_ieee.c.

302 {
303  r->f = a->f * b->f / 100.;
304 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_or_f()

static void rpn_or_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 177 of file rpn_ieee.c.

178 {
179  calc_number_t ai, bi;
180 
181  ai.i = logic_dbl2int(a);
182  bi.i = logic_dbl2int(b);
183 
184  r->f = (long double)(ai.i | bi.i);
185 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
INT64 i
Definition: calc.h:127
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_or_i()

static void rpn_or_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 270 of file rpn_ieee.c.

271 {
272  r->i = a->i | b->i;
273 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_pow_f()

static void rpn_pow_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 215 of file rpn_ieee.c.

216 {
217  r->f = pow(a->f, b->f);
218  if (_finite(r->f) == 0 || _isnan(r->f))
219  calc.is_nan = TRUE;
220 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL is_nan
Definition: calc.h:183
float pow(float __x, int __y)
Definition: _cmath.h:458
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

◆ rpn_shl_f()

static void rpn_shl_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 197 of file rpn_ieee.c.

198 {
200 
201  modf(b->f, &n.f);
202 
203  r->f = a->f * pow(2., n.f);
204 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
float pow(float __x, int __y)
Definition: _cmath.h:458
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_shl_i()

static void rpn_shl_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 280 of file rpn_ieee.c.

281 {
282  r->i = a->i << b->i;
283 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_shr_f()

static void rpn_shr_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 206 of file rpn_ieee.c.

207 {
209 
210  modf(b->f, &n.f);
211 
212  r->f = a->f / pow(2., n.f);
213 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
float pow(float __x, int __y)
Definition: _cmath.h:458
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_shr_i()

static void rpn_shr_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 285 of file rpn_ieee.c.

286 {
287  r->i = a->i >> b->i;
288 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_sqr_f()

static void rpn_sqr_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 222 of file rpn_ieee.c.

223 {
224  if (b->f == 0)
225  calc.is_nan = TRUE;
226  else {
227  r->f = pow(a->f, 1./b->f);
228  if (_finite(r->f) == 0 || _isnan(r->f))
229  calc.is_nan = TRUE;
230  }
231 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL is_nan
Definition: calc.h:183
float pow(float __x, int __y)
Definition: _cmath.h:458
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

◆ rpn_sub_f()

static void rpn_sub_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 137 of file rpn_ieee.c.

138 {
139  r->f = a->f - b->f;
140 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_sub_i()

static void rpn_sub_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 239 of file rpn_ieee.c.

240 {
241  r->i = a->i - b->i;
242 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_sub_p()

static void rpn_sub_p ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 296 of file rpn_ieee.c.

297 {
298  r->f = a->f * (1. - b->f/100.);
299 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_xor_f()

static void rpn_xor_f ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 187 of file rpn_ieee.c.

188 {
189  calc_number_t ai, bi;
190 
191  ai.i = logic_dbl2int(a);
192  bi.i = logic_dbl2int(b);
193 
194  r->f = (long double)(ai.i ^ bi.i);
195 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
INT64 i
Definition: calc.h:127
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ rpn_xor_i()

static void rpn_xor_i ( calc_number_t r,
calc_number_t a,
calc_number_t b 
)
static

Definition at line 275 of file rpn_ieee.c.

276 {
277  r->i = a->i ^ b->i;
278 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ run_operator()

void run_operator ( calc_node_t result,
calc_node_t a,
calc_node_t b,
unsigned int  operation 
)

Definition at line 314 of file rpn_ieee.c.

318 {
319  calc_number_t da, db, dc;
320  DWORD base = calc.base;
321 
322  da = a->number;
323  db = b->number;
324  if (a->base == IDC_RADIO_DEC && b->base != IDC_RADIO_DEC) {
325  db.f = logic_int2dbl(&b->number);
327  } else
328  if (a->base != IDC_RADIO_DEC && b->base == IDC_RADIO_DEC) {
329  da.f = logic_int2dbl(&a->number);
331  }
332 
333  if (base == IDC_RADIO_DEC) {
334  if (percent_mode) {
336  operator_list[operation].op_p(&dc, &da, &db);
337  } else
338  operator_list[operation].op_f(&dc, &da, &db);
339  if (_finite(dc.f) == 0)
340  calc.is_nan = TRUE;
341  } else {
342  operator_list[operation].op_i(&dc, &da, &db);
343  /* apply final limiter to result */
344  apply_int_mask(&dc);
345  }
346 
347  if (a->base == IDC_RADIO_DEC && b->base != IDC_RADIO_DEC) {
348  result->number.i = logic_dbl2int(&dc);
349  apply_int_mask(&result->number);
350  } else
351  if (a->base != IDC_RADIO_DEC && b->base == IDC_RADIO_DEC)
352  result->number.f = dc.f;
353  else
354  result->number = dc;
355 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:22
double f
Definition: calc.h:126
HDC dc
Definition: cylfrac.c:34
double logic_int2dbl(calc_number_t *a)
Definition: fun_ieee.c:275
BOOL is_nan
Definition: calc.h:183
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
static const calc_operator_t operator_list[]
Definition: rpn_ieee.c:72
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
unsigned long DWORD
Definition: ntddk_ex.h:95
operator_call op_f
Definition: rpn_ieee.c:32
operator_call op_i
Definition: rpn_ieee.c:33
operator_call op_p
Definition: rpn_ieee.c:34
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247
GLuint64EXT * result
Definition: glext.h:11304
void apply_int_mask(calc_number_t *a)
Definition: fun_ieee.c:26
static BOOL percent_mode
Definition: rpn_ieee.c:39

Referenced by evalStack(), and exec_closeparent().

◆ start_rpn_engine()

void start_rpn_engine ( void  )

Definition at line 479 of file rpn_ieee.c.

480 {
481  stack = NULL;
482 }
smooth NULL
Definition: ftsmooth.c:416
Definition: _stack.h:47

◆ stop_rpn_engine()

void stop_rpn_engine ( void  )

Definition at line 484 of file rpn_ieee.c.

485 {
486 }

Variable Documentation

◆ operator_list

const calc_operator_t operator_list[]
static
Initial value:
= {
{ 0, NULL, NULL, NULL, },
{ 0, NULL, NULL, NULL, },
{ 0, NULL, NULL, NULL, },
{ 1, rpn_or_f, rpn_or_i, NULL, },
{ 2, rpn_xor_f, rpn_xor_i, NULL, },
{ 3, rpn_and_f, rpn_and_i, NULL, },
{ 4, rpn_shl_f, rpn_shl_i, NULL, },
{ 4, rpn_shr_f, rpn_shr_i, NULL, },
{ 6, rpn_mod_f, rpn_mod_i, NULL, },
{ 7, rpn_pow_f, NULL, NULL, },
{ 7, rpn_sqr_f, NULL, NULL, },
}
static void rpn_mod_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:257
static void rpn_sub_p(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:296
static void rpn_sub_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:239
static void rpn_mul_p(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:301
static void rpn_sqr_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:222
static void rpn_xor_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:275
static void rpn_or_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:270
static void rpn_div_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:249
static void rpn_add_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:234
static void rpn_mul_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:244
static void rpn_and_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:167
static void rpn_mod_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:155
static void rpn_shl_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:280
static void rpn_div_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:147
smooth NULL
Definition: ftsmooth.c:416
static void rpn_xor_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:187
static void rpn_shl_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:197
static void rpn_shr_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:206
static void rpn_add_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:132
static void rpn_mul_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:142
static void rpn_add_p(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:291
static void rpn_div_p(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:306
static void rpn_or_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:177
static void rpn_pow_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:215
static void rpn_shr_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:285
static void rpn_and_i(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:265
static void rpn_sub_f(calc_number_t *r, calc_number_t *a, calc_number_t *b)
Definition: rpn_ieee.c:137

Definition at line 72 of file rpn_ieee.c.

Referenced by evalStack(), and run_operator().

◆ percent_mode

BOOL percent_mode
static

Definition at line 39 of file rpn_ieee.c.

Referenced by exec_infix2postfix(), and run_operator().

◆ stack

◆ temp

calc_node_t temp
static

Definition at line 38 of file rpn_ieee.c.

Referenced by __ieee754_jn(), __ieee754_yn(), __readmsr(), _aligned_offset_malloc(), _aligned_offset_realloc(), _chm_find_in_PMGL(), _chm_parse_cword(), _getopt_internal(), _getopt_internal_r(), _hypot(), _lzx_get_bytes(), _unmarshal_int64(), _unmarshal_uint64(), accel_fill_rect(), accel_screen_copy(), acpi_bus_get_flags(), add_diff(), AddToRingBuffer(), aes_setup(), vertexArray::appendVertex(), arcLoopToDLineLoop(), arith_decode(), arith_encode(), AtapiHexToString(), AVISplitter_ProcessOldIndex(), bezierPatchDeleteList(), bezierPatchListDraw(), bezierPatchMeshEndStrip(), bezierPatchMeshInsertUV(), bezierPatchMeshListCollect(), bezierPatchMeshListDelDeg(), bezierPatchMeshListDraw(), bezierPatchMeshListEval(), bezierPatchMeshListNumTriangles(), bezierPatchMeshListPrint(), bezierPatchMeshListReverse(), bezierPatchMeshListTotalStrips(), bezierPatchMeshListTotalVert(), bezierPatchPrintList(), bin_to_DLineLoops(), Bus_PDO_QueryDeviceId(), Bus_PlugInDevice(), CC_PaintTriangle(), CdRomFindFeaturePage(), cf2_interpT2CharString(), cff_face_init(), cfgets(), monoChain::chainIntersectHoriz(), check_leased_list(), check_messages(), check_no_duplicates(), check_version(), cid_parse_font_matrix(), COMM_BuildNewCommDCB(), COMM_ParseByteSize(), COMM_ParseStopBits(), COMMAND_PROTOTYPE(), CommaSeparateNumberString(), confirm_lease(), convert_file_list(), convert_text2number_2(), ConvertTokenToModule(), ConvertTokenToModuleAndName(), ConvertTokenToSymbol(), ConvertULargeInteger(), copy_data_blocks(), copy_mipmap_chain(), CREATE_CreateView(), create_file_test(), CreateTemplateDialog(), CRYPT_AsnDecodeBitsSwapBytes(), CRYPT_EncodeLen(), CRYPT_LoadSIP(), CryptAcquireContextW(), directedLine::cutIntersectionAllPoly(), directedLine::cutoffPolygon(), d3d_device7_Load(), d3dcompiler_parse_type(), D3DReflect(), D3DRMQuaternionMultiply(), D3DRMQuaternionSlerp(), D3DRMVectorAdd(), D3DRMVectorCrossProduct(), D3DRMVectorReflect(), D3DRMVectorScale(), D3DRMVectorSubtract(), D3DXComputeBoundingSphere(), D3DXMatrixMultiplyTranspose(), D3DXMatrixTransformation(), D3DXPlaneIntersectLine(), D3DXQuaternionRotationAxis(), D3DXQuaternionSlerp(), D3DXSHEvalConeLight(), D3DXSHEvalDirectionalLight(), D3DXSHEvalHemisphereLight(), D3DXSHEvalSphericalLight(), D3DXSHRotate(), DBG_check(), DBG_checkConnectivity(), DBG_collectSampledLinesAllPoly(), DBG_collectSampledLinesPoly(), DBG_cutIntersectionAllPoly(), DBG_edgeIntersectChainD(), DBG_edgeIntersectPoly(), DBG_enclosingPolygons(), DBG_is_U_direction(), DBG_is_U_monotone(), DBG_isConvex(), DBG_polygonListIntersect(), DBG_polygonsIntersect(), DBG_rayIntersectPoly(), DBG_reverse(), DeckClickProc(), DecodeVmFlags(), DecompressBitmap(), decrypt_byte(), deformat_string_internal(), directedLine::deleteDegenerateLines(), directedLine::deleteDegenerateLinesAllPolygons(), sampledLine::deleteList(), monoChain::deleteLoop(), monoChain::deleteLoopList(), directedLine::deletePolygonList(), directedLine::deletePolygonListWithSline(), directedLine::deleteSinglePolygon(), directedLine::deleteSinglePolygonWithSline(), device_disabled_registry(), DIALOG_DlgDirListW(), dictionary_remove(), directedLineLoopListToMonoChainLoopList(), directedLineLoopToMonoChainLoop(), DirPrintWideList(), DirReadParam(), Subdivider::drawSurfaces(), DSOUND_RecalcVolPan(), EMFDRV_ArcChordPie(), EMFDRV_Ellipse(), EMFDRV_Rectangle(), EMFDRV_RoundRect(), EMFDRV_UpdateBBox(), emit_eobrun(), encode_mcu_AC_first(), encode_mcu_AC_refine(), encode_mcu_DC_first(), encode_one_block(), primStream::end(), TTelnetHandler::escapeIAC(), exchange(), ext2_expand_block(), ext2_get_block(), ExtractTypeName(), FD31_StripEditControl(), FFSExpandBlock(), FFSTruncateBlock(), FFSv1GetBlock(), FFSv2GetBlock(), file_stat(), FilterGraph2_Connect(), FilterMapper3_EnumMatchingFilters(), monoChain::find(), find_lease(), findDiagonal_singleCuspX(), findInteriorCuspsX(), findNeckF(), FindParenCount(), directedLine::findRoot(), finish_pass(), forward_DCT(), FT_DivFix(), FT_MulDiv(), FT_MulDiv_No_Round(), FT_Raccess_Get_DataOffsets(), ft_smooth_render_generic(), ftc_snode_load(), GdipGetPathWorldBounds(), get_default_domain(), get_temp_filename(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::GetDisplayNameOf(), GetTempPathW(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), handle_try(), htest_one_block(), ID3DXMatrixStackImpl_RotateAxis(), ID3DXMatrixStackImpl_RotateAxisLocal(), ID3DXMatrixStackImpl_RotateYawPitchRoll(), ID3DXMatrixStackImpl_RotateYawPitchRollLocal(), ID3DXMatrixStackImpl_Scale(), ID3DXMatrixStackImpl_ScaleLocal(), ID3DXMatrixStackImpl_Translate(), ID3DXMatrixStackImpl_TranslateLocal(), IDirectPlayLobby3AImpl_RunApplication(), OpenGLSurfaceEvaluator::inBPMEvalEM(), OpenGLSurfaceEvaluator::inBPMListEval(), OpenGLSurfaceEvaluator::inBPMListEvalEM(), OpenGLSurfaceEvaluator::inEvalULine(), OpenGLSurfaceEvaluator::inEvalVLine(), init(), init_leases_list(), OpenGLCurveEvaluator::inPreEvaluate(), OpenGLSurfaceEvaluator::inPreEvaluate(), OpenGLSurfaceEvaluator::inPreEvaluateWithDeriv(), reflexChain::insert(), rectBlockArray::insert(), primStream::insert(), INSERT_CreateView(), IntGetProp(), invert_matrix_3d(), is_mip_level_subset(), IsModuleLoaded(), directedLine::isPolygon(), jpeg_add_quant_table(), LoadSymbolsFromConfig(), main(), MainWndProc(), make_tmp_file(), OpenGLSurfaceEvaluator::map2f(), matrix_multiply(), monoChain::monoChain(), monoTriangulationLoop(), monoTriangulationRec(), monoTriangulationRecGenOpt(), CardRegion::MoveCard(), mrp_EnumComponentCosts(), msi_check_product_patches(), MsiEnumComponentCostsA(), MsiEnumComponentCostsW(), MsiSIPGetSignedDataMsg(), multiply_matrix(), multiply_vector_matrix(), names_dump(), NewGame(), CEnumIDListBase::Next(), CEnumIDList::Next(), monoChain::numChainsAllLoops(), monoChain::numChainsSingleLoop(), directedLine::numEdges(), directedLine::numEdgesAllPolygons(), numInteriorCuspsX(), o_curve_to_DLineLoop(), o_trim_to_DLineLoops(), CAttributesDialog::OnInitDialog(), CardRegion::OnLButtonUp(), parse_charstrings(), parse_subrs(), PATH_Arc(), PATH_CheckCorners(), PB_Read(), PDEVOBJ_vSwitchPdev(), directedLine::polyArea(), polygonConvert(), pop(), prepare_clip_space_planes(), prepare_rpn_result_2(), monoChain::printAllLoops(), directedLine::printAllPolygons(), monoChain::printChainLoop(), PrintkCallback(), directedLine::printList(), monoChain::printOneChain(), process_stabs(), PropertyStorage_WritePropertyToStream(), PropertyStore_SetValue(), PropertyStore_SetValueAndState(), PROPSHEET_CreateDialog(), ProtocolReceive(), ps_mask_table_merge(), ps_parser_load_field(), QTMupdatemodel(), raise(), ReadfromSMBus(), hda_controller::ReadModifyWrite16(), hda_controller::ReadModifyWrite32(), hda_controller::ReadModifyWrite8(), ReadPhysMem(), real_path(), reg_get_value(), REGION_CopyRegion(), REGION_CropRegion(), REGION_PtsToRegion(), release_lease(), remglob(), CardStack::RemoveCard(), RemoveFile(), replace_backslashes(), CardStack::Reverse(), reverse(), reverse_bgr8(), RevirtualizeBreakpointsForModule(), RtlDeleteTimerQueueEx(), RtlIntegerToUnicode(), directedLine::samePolygon(), sampleCompRight(), sampleLeftOneGridStep(), sampleRightOneGridStep(), scale_internal(), scale_internal_byte(), scale_internal_float(), scale_internal_int(), scale_internal_short(), scale_internal_ubyte(), scale_internal_uint(), scale_internal_ushort(), scaleInternal3D(), scaleInternalPackedPixel(), ScanExports(), ScanExportsByAddress(), SetMacro(), setup_mix(), CardStack::Shuffle(), signal(), START_TEST(), Stream_LoadString(), swap(), t1_parse_font_matrix(), t42_parse_font_matrix(), sampledLine::tessellate(), sampledLine::tessellateAll(), test_calchash(), test_collection(), test_EnumChildContainerNames(), test_EnumPropNames(), test_FDIIsCabinet(), test_filesourcefilter(), test_GetAdaptersAddresses(), test_getat(), Test_GetMonitorFrequency(), test_incorrect_api_usage(), test_invalid_callbackA(), test_invalid_callbackW(), test_invalid_parametersA(), test_invalid_parametersW(), Test_MouseSpeed(), test_MsiEnumComponentCosts(), test_PlaySound(), test_propertystore(), test_publish(), test_publish_product(), test_register_product(), test_Sdb(), test_SetupDecompressOrCopyFile(), test_SetupGetFileCompressionInfo(), test_SetupGetFileCompressionInfoEx(), test_simple_enumerationA(), test_simple_enumerationW(), test_toplevel_stat(), test_unicode(), test_WritePrivateProfileString(), to_upper(), monoChain::toArrayAllLoops(), directedLine::toArrayAllPolygons(), monoChain::toArraySingleLoop(), directedLine::toArraySinglePolygon(), transform_region_element(), transpose_matrix(), TreeNodeMaximum(), TreeNodeMinimum(), TreeView_GetRealSubtreeState(), triangulateRectGen(), TruncateString(), TuiEditBox(), TuiMessageBoxCritical(), ui_screenblt(), TScroller::update(), UpdateBtnStates(), UPDOWN_HandleMouseEvent(), UpDownWindowProc(), VarAbs(), VarBstrFromDec(), VarFix(), VarInt(), VarNeg(), VarNot(), VarRound(), VfdCheckHandlers(), VfdRegisterHandlers(), VfdUnregisterHandlers(), VgaZeroVideoMemory(), VisualizeFlags(), wave_header_flags(), whilePaintingL(), wined3d_device_multiply_transform(), write_conformant_array_pointer_descriptions(), write_fixed_array_pointer_descriptions(), write_varying_array_pointer_descriptions(), directedLine::writeAllPolygons(), WritePhysMem(), TConsole::WriteString(), WriteToSMBus(), xmlAddDefAttrs(), xmlCleanupThreads(), xmlPathToURI(), xmlSaveUri(), xmlSaveUriRealloc(), xmlURIEscapeStr(), ZSTD_decodeSequence(), and ZSTD_decodeSequenceLong().