ReactOS  0.4.13-dev-551-gf37fb1f
fun_ieee.c File Reference
#include "calc.h"
Include dependency graph for fun_ieee.c:

Go to the source code of this file.

Macros

#define NEXT(n, i)   (((n) + (i)/(n)) >> 1)
 

Functions

static double validate_rad2angle (double a)
 
static double validate_angle2rad (calc_number_t *c)
 
void apply_int_mask (calc_number_t *r)
 
double asinh (double x)
 
double acosh (double x)
 
double atanh (double x)
 
void rpn_sin (calc_number_t *c)
 
void rpn_cos (calc_number_t *c)
 
void rpn_tan (calc_number_t *c)
 
void rpn_asin (calc_number_t *c)
 
void rpn_acos (calc_number_t *c)
 
void rpn_atan (calc_number_t *c)
 
void rpn_sinh (calc_number_t *c)
 
void rpn_cosh (calc_number_t *c)
 
void rpn_tanh (calc_number_t *c)
 
void rpn_asinh (calc_number_t *c)
 
void rpn_acosh (calc_number_t *c)
 
void rpn_atanh (calc_number_t *c)
 
void rpn_int (calc_number_t *c)
 
void rpn_frac (calc_number_t *c)
 
void rpn_reci (calc_number_t *c)
 
void rpn_fact (calc_number_t *c)
 
__int64 logic_dbl2int (calc_number_t *a)
 
double logic_int2dbl (calc_number_t *a)
 
void rpn_not (calc_number_t *c)
 
void rpn_pi (calc_number_t *c)
 
void rpn_2pi (calc_number_t *c)
 
void rpn_sign (calc_number_t *c)
 
void rpn_exp2 (calc_number_t *c)
 
void rpn_exp3 (calc_number_t *c)
 
static __int64 myabs64 (__int64 number)
 
static unsigned __int64 sqrti (unsigned __int64 number)
 
void rpn_sqrt (calc_number_t *c)
 
static __int64 cbrti (__int64 x)
 
void rpn_cbrt (calc_number_t *c)
 
void rpn_exp (calc_number_t *c)
 
void rpn_exp10 (calc_number_t *c)
 
void rpn_ln (calc_number_t *c)
 
void rpn_log (calc_number_t *c)
 
static double stat_sum (void)
 
static double stat_sum2 (void)
 
void rpn_ave (calc_number_t *c)
 
void rpn_ave2 (calc_number_t *c)
 
void rpn_sum (calc_number_t *c)
 
void rpn_sum2 (calc_number_t *c)
 
static void rpn_s_ex (calc_number_t *c, int pop_type)
 
void rpn_s (calc_number_t *c)
 
void rpn_s_m1 (calc_number_t *c)
 
void rpn_dms2dec (calc_number_t *c)
 
void rpn_dec2dms (calc_number_t *c)
 
void rpn_zero (calc_number_t *c)
 
void rpn_copy (calc_number_t *dst, calc_number_t *src)
 
int rpn_is_zero (calc_number_t *c)
 
void rpn_alloc (calc_number_t *c)
 
void rpn_free (calc_number_t *c)
 

Macro Definition Documentation

◆ NEXT

#define NEXT (   n,
  i 
)    (((n) + (i)/(n)) >> 1)

Function Documentation

◆ acosh()

double acosh ( double  x)

Definition at line 54 of file fun_ieee.c.

55 {
56  // must be x>=1, if not return Nan (Not a Number)
57  if(!(x>=1.0)) return sqrt(-1.0);
58 
59  // return only the positive result (as sqrt does).
60  return log(x+sqrt(x*x-1.0));
61 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define log(outFile, fmt,...)
Definition: util.h:15

Referenced by rpn_acosh().

◆ apply_int_mask()

void apply_int_mask ( calc_number_t r)

Definition at line 26 of file fun_ieee.c.

27 {
28  unsigned __int64 mask;
29 
30  switch (calc.size) {
31  case IDC_RADIO_QWORD:
32  mask = _UI64_MAX;
33  break;
34  case IDC_RADIO_DWORD:
35  mask = ULONG_MAX;
36  break;
37  case IDC_RADIO_WORD:
38  mask = USHRT_MAX;
39  break;
40  case IDC_RADIO_BYTE:
41  mask = UCHAR_MAX;
42  break;
43  default:
44  mask = (unsigned __int64)-1;
45  }
46  r->i &= mask;
47 }
#define _UI64_MAX
Definition: limits.h:63
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define IDC_RADIO_WORD
Definition: resource.h:84
#define USHRT_MAX
Definition: limits.h:38
GLenum GLint GLuint mask
Definition: glext.h:6028
#define IDC_RADIO_QWORD
Definition: resource.h:82
DWORD size
Definition: calc.h:190
#define UCHAR_MAX
Definition: limits.h:25
#define IDC_RADIO_DWORD
Definition: resource.h:83
calc_t calc
Definition: winmain.c:247
#define ULONG_MAX
Definition: limits.h:44
#define __int64
Definition: basetyps.h:16
#define IDC_RADIO_BYTE
Definition: resource.h:85

◆ asinh()

double asinh ( double  x)

Definition at line 49 of file fun_ieee.c.

50 {
51  return log(x+sqrt(x*x+1));
52 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define log(outFile, fmt,...)
Definition: util.h:15

Referenced by rpn_asinh().

◆ atanh()

double atanh ( double  x)

Definition at line 63 of file fun_ieee.c.

64 {
65  // must be x>-1, x<1, if not return Nan (Not a Number)
66  if(!(x>-1.0 && x<1.0)) return sqrt(-1.0);
67 
68  return log((1.0+x)/(1.0-x))/2.0;
69 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define log(outFile, fmt,...)
Definition: util.h:15

Referenced by rpn_atanh().

◆ cbrti()

static __int64 cbrti ( __int64  x)
static

Definition at line 370 of file fun_ieee.c.

370  {
371  __int64 s, y, b;
372 
373  s = 60;
374  y = 0;
375  while(s >= 0) {
376  y = 2*y;
377  b = (3*y*(y + 1) + 1) << s;
378  s = s - 3;
379  if (x >= b) {
380  x = x - b;
381  y = y + 1;
382  }
383  }
384  return y;
385 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLdouble s
Definition: gl.h:2039
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define __int64
Definition: basetyps.h:16

Referenced by rpn_cbrt().

◆ logic_dbl2int()

__int64 logic_dbl2int ( calc_number_t a)

Definition at line 261 of file fun_ieee.c.

262 {
263  double int_part;
264  int width;
265 
266  modf(a->f, &int_part);
267  width = (int_part==0) ? 1 : (int)log10(fabs(int_part))+1;
268  if (width > 63) {
269  calc.is_nan = TRUE;
270  return 0;
271  }
272  return (__int64)int_part;
273 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:183
_STLP_DECLSPEC complex< float > _STLP_CALL log10(const complex< float > &)
Definition: complex.cpp:230
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

Referenced by rpn_and_f(), rpn_not(), rpn_or_f(), rpn_xor_f(), and run_operator().

◆ logic_int2dbl()

double logic_int2dbl ( calc_number_t a)

Definition at line 275 of file fun_ieee.c.

276 {
277  return (double)a->i;
278 }
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by run_operator().

◆ myabs64()

static __int64 myabs64 ( __int64  number)
static

Definition at line 328 of file fun_ieee.c.

329 {
330  return (number < 0) ? 0-number : number;
331 }
static size_t double number
Definition: printf.c:64

Referenced by sqrti().

◆ rpn_2pi()

void rpn_2pi ( calc_number_t c)

Definition at line 295 of file fun_ieee.c.

296 {
297  c->f = CALC_PI*2;
298 }
const GLubyte * c
Definition: glext.h:8905
#define CALC_PI
Definition: calc.h:212

◆ rpn_acos()

void rpn_acos ( calc_number_t c)

Definition at line 150 of file fun_ieee.c.

151 {
152  c->f = validate_rad2angle(acos(c->f));
153  if (_isnan(c->f))
154  calc.is_nan = TRUE;
155 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
valarray< _Tp > acos(const valarray< _Tp > &__x)
Definition: _valarray.h:901
const GLubyte * c
Definition: glext.h:8905
static double validate_rad2angle(double a)
Definition: fun_ieee.c:71
calc_t calc
Definition: winmain.c:247

◆ rpn_acosh()

void rpn_acosh ( calc_number_t c)

Definition at line 188 of file fun_ieee.c.

189 {
190  c->f = acosh(c->f);
191  if (_isnan(c->f))
192  calc.is_nan = TRUE;
193 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
double acosh(double x)
Definition: fun_ieee.c:54
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_alloc()

void rpn_alloc ( calc_number_t c)

Definition at line 601 of file fun_ieee.c.

602 {
603 }

◆ rpn_asin()

void rpn_asin ( calc_number_t c)

Definition at line 144 of file fun_ieee.c.

145 {
146  c->f = validate_rad2angle(asin(c->f));
147  if (_isnan(c->f))
148  calc.is_nan = TRUE;
149 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
valarray< _Tp > asin(const valarray< _Tp > &__x)
Definition: _valarray.h:910
const GLubyte * c
Definition: glext.h:8905
static double validate_rad2angle(double a)
Definition: fun_ieee.c:71
calc_t calc
Definition: winmain.c:247

◆ rpn_asinh()

void rpn_asinh ( calc_number_t c)

Definition at line 182 of file fun_ieee.c.

183 {
184  c->f = asinh(c->f);
185  if (_isnan(c->f))
186  calc.is_nan = TRUE;
187 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
double asinh(double x)
Definition: fun_ieee.c:49
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_atan()

void rpn_atan ( calc_number_t c)

Definition at line 156 of file fun_ieee.c.

157 {
158  c->f = validate_rad2angle(atan(c->f));
159  if (_isnan(c->f))
160  calc.is_nan = TRUE;
161 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
valarray< _Tp > atan(const valarray< _Tp > &__x)
Definition: _valarray.h:919
static double validate_rad2angle(double a)
Definition: fun_ieee.c:71
calc_t calc
Definition: winmain.c:247

◆ rpn_atanh()

void rpn_atanh ( calc_number_t c)

Definition at line 194 of file fun_ieee.c.

195 {
196  c->f = atanh(c->f);
197  if (_isnan(c->f))
198  calc.is_nan = TRUE;
199 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
double atanh(double x)
Definition: fun_ieee.c:63
calc_t calc
Definition: winmain.c:247

◆ rpn_ave()

void rpn_ave ( calc_number_t c)

Definition at line 467 of file fun_ieee.c.

468 {
469  double ave = 0;
470  int n;
471 
472  ave = stat_sum();
474 
475  if (n)
476  ave = ave / (double)n;
477  if (calc.base == IDC_RADIO_DEC)
478  c->f = ave;
479  else
480  c->i = (__int64)ave;
481 }
DWORD base
Definition: calc.h:189
static double stat_sum(void)
Definition: fun_ieee.c:437
#define IDC_RADIO_DEC
Definition: resource.h:22
GLdouble n
Definition: glext.h:7729
#define SendDlgItemMessage
Definition: winuser.h:5708
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define LB_GETCOUNT
Definition: winuser.h:1999
const GLubyte * c
Definition: glext.h:8905
HWND hStatWnd
Definition: calc.h:193
#define IDC_LIST_STAT
Definition: resource.h:96
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16

◆ rpn_ave2()

void rpn_ave2 ( calc_number_t c)

Definition at line 483 of file fun_ieee.c.

484 {
485  double ave = 0;
486  int n;
487 
488  ave = stat_sum2();
490 
491  if (n)
492  ave = ave / (double)n;
493  if (calc.base == IDC_RADIO_DEC)
494  c->f = ave;
495  else
496  c->i = (__int64)ave;
497 }
DWORD base
Definition: calc.h:189
#define IDC_RADIO_DEC
Definition: resource.h:22
GLdouble n
Definition: glext.h:7729
#define SendDlgItemMessage
Definition: winuser.h:5708
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
#define LB_GETCOUNT
Definition: winuser.h:1999
const GLubyte * c
Definition: glext.h:8905
HWND hStatWnd
Definition: calc.h:193
#define IDC_LIST_STAT
Definition: resource.h:96
static double stat_sum2(void)
Definition: fun_ieee.c:452
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16

◆ rpn_cbrt()

void rpn_cbrt ( calc_number_t c)

Definition at line 387 of file fun_ieee.c.

388 {
389  if (calc.base == IDC_RADIO_DEC)
390 #if defined(__GNUC__) && !defined(__REACTOS__)
391  c->f = cbrt(c->f);
392 #else
393  c->f = pow(c->f,1./3.);
394 #endif
395  else {
396  c->i = cbrti(c->i);
397  }
398 }
DWORD base
Definition: calc.h:189
#define IDC_RADIO_DEC
Definition: resource.h:22
double __cdecl cbrt(double)
float pow(float __x, int __y)
Definition: _cmath.h:458
const GLubyte * c
Definition: glext.h:8905
static __int64 cbrti(__int64 x)
Definition: fun_ieee.c:370
calc_t calc
Definition: winmain.c:247

◆ rpn_copy()

void rpn_copy ( calc_number_t dst,
calc_number_t src 
)

Definition at line 591 of file fun_ieee.c.

592 {
593  *dst = *src;
594 }
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ rpn_cos()

void rpn_cos ( calc_number_t c)

Definition at line 116 of file fun_ieee.c.

117 {
118  double angle = validate_angle2rad(c);
119 
120  if (angle == CALC_PI_2 || angle == CALC_3_PI_2)
121  c->f = 0;
122  else
123  if (angle == CALC_PI)
124  c->f = -1;
125  else
126  if (angle == CALC_2_PI)
127  c->f = 1;
128  else
129  c->f = cos(angle);
130 }
static double validate_angle2rad(calc_number_t *c)
Definition: fun_ieee.c:86
#define CALC_3_PI_2
Definition: calc.h:213
GLfloat angle
Definition: glext.h:10853
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define CALC_2_PI
Definition: calc.h:214
#define CALC_PI_2
Definition: calc.h:211
const GLubyte * c
Definition: glext.h:8905
#define CALC_PI
Definition: calc.h:212

◆ rpn_cosh()

void rpn_cosh ( calc_number_t c)

Definition at line 169 of file fun_ieee.c.

170 {
171  c->f = cosh(c->f);
172  if (_isnan(c->f))
173  calc.is_nan = TRUE;
174 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
_STLP_DECLSPEC complex< float > _STLP_CALL cosh(const complex< float > &)
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_dec2dms()

void rpn_dec2dms ( calc_number_t c)

Definition at line 577 of file fun_ieee.c.

578 {
579  double d, m, s;
580 
581  m = modf(c->f, &d) * 60;
582  s = ceil(modf(m, &m) * 60);
583  c->f = d + m/100. + s/10000.;
584 }
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
const GLfloat * m
Definition: glext.h:10848
#define d
Definition: ke_i.h:81
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_dms2dec()

void rpn_dms2dec ( calc_number_t c)

Definition at line 563 of file fun_ieee.c.

564 {
565  double d, m, s;
566 
567  m = modf(c->f, &d) * 100;
568  s = (modf(m, &m) * 100)+.5;
569  modf(s, &s);
570 
571  m = m/60;
572  s = s/3600;
573 
574  c->f = d + m + s;
575 }
const GLfloat * m
Definition: glext.h:10848
#define d
Definition: ke_i.h:81
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_exp()

void rpn_exp ( calc_number_t c)

Definition at line 400 of file fun_ieee.c.

401 {
402  c->f = exp(c->f);
403  if (_finite(c->f) == 0)
404  calc.is_nan = TRUE;
405 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:183
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
const GLubyte * c
Definition: glext.h:8905
DWORD exp
Definition: msg.c:15681
calc_t calc
Definition: winmain.c:247

◆ rpn_exp10()

void rpn_exp10 ( calc_number_t c)

Definition at line 407 of file fun_ieee.c.

408 {
409  double int_part;
410 
411  modf(c->f, &int_part);
412  if (fmod(int_part, 2.) == 0.)
413  calc.is_nan = TRUE;
414  else {
415  c->f = pow(10., c->f);
416  if (_finite(c->f) == 0)
417  calc.is_nan = TRUE;
418  }
419 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:183
float pow(float __x, int __y)
Definition: _cmath.h:458
_Check_return_ double __cdecl fmod(_In_ double x, _In_ double y)
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_exp2()

void rpn_exp2 ( calc_number_t c)

Definition at line 308 of file fun_ieee.c.

309 {
310  if (calc.base == IDC_RADIO_DEC) {
311  c->f *= c->f;
312  if (_finite(c->f) == 0)
313  calc.is_nan = TRUE;
314  } else
315  c->i *= c->i;
316 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:22
BOOL is_nan
Definition: calc.h:183
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_exp3()

void rpn_exp3 ( calc_number_t c)

Definition at line 318 of file fun_ieee.c.

319 {
320  if (calc.base == IDC_RADIO_DEC) {
321  c->f = pow(c->f, 3.);
322  if (_finite(c->f) == 0)
323  calc.is_nan = TRUE;
324  } else
325  c->i *= (c->i*c->i);
326 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:22
BOOL is_nan
Definition: calc.h:183
float pow(float __x, int __y)
Definition: _cmath.h:458
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_fact()

void rpn_fact ( calc_number_t c)

Definition at line 224 of file fun_ieee.c.

225 {
226  double fact, mult, num;
227 
228  if (calc.base == IDC_RADIO_DEC)
229  num = c->f;
230  else
231  num = (double)c->i;
232  if (num > 1000) {
233  calc.is_nan = TRUE;
234  return;
235  }
236  if (num < 0) {
237  calc.is_nan = TRUE;
238  return;
239  } else
240  if (num == 0)
241  fact = 1;
242  else {
243  rpn_int(c);
244  fact = 1;
245  mult = 2;
246  while (mult <= num) {
247  fact *= mult;
248  mult++;
249  }
250  c->f = fact;
251  }
252  if (_finite(fact) == 0)
253  calc.is_nan = TRUE;
254  else
255  if (calc.base == IDC_RADIO_DEC)
256  c->f = fact;
257  else
258  c->i = (__int64)fact;
259 }
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:22
BOOL is_nan
Definition: calc.h:183
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
if(!(yy_init))
Definition: macro.lex.yy.c:714
void rpn_int(calc_number_t *c)
Definition: fun_ieee.c:201
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
const GLubyte * c
Definition: glext.h:8905
GLuint GLuint num
Definition: glext.h:9618
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16

◆ rpn_frac()

void rpn_frac ( calc_number_t c)

Definition at line 209 of file fun_ieee.c.

210 {
211  double int_part;
212 
213  c->f = modf(calc.code.f, &int_part);
214 }
calc_number_t code
Definition: calc.h:178
double f
Definition: calc.h:126
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_free()

void rpn_free ( calc_number_t c)

Definition at line 605 of file fun_ieee.c.

606 {
607 }

◆ rpn_int()

void rpn_int ( calc_number_t c)

Definition at line 201 of file fun_ieee.c.

202 {
203  double int_part;
204 
205  modf(calc.code.f, &int_part);
206  c->f = int_part;
207 }
calc_number_t code
Definition: calc.h:178
double f
Definition: calc.h:126
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

Referenced by rpn_fact().

◆ rpn_is_zero()

int rpn_is_zero ( calc_number_t c)

Definition at line 596 of file fun_ieee.c.

597 {
598  return (c->f == 0);
599 }
const GLubyte * c
Definition: glext.h:8905

◆ rpn_ln()

void rpn_ln ( calc_number_t c)

Definition at line 421 of file fun_ieee.c.

422 {
423  if (c->f <= 0)
424  calc.is_nan = TRUE;
425  else
426  c->f = log(c->f);
427 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247
#define log(outFile, fmt,...)
Definition: util.h:15

◆ rpn_log()

void rpn_log ( calc_number_t c)

Definition at line 429 of file fun_ieee.c.

430 {
431  if (c->f <= 0)
432  calc.is_nan = TRUE;
433  else
434  c->f = log10(c->f);
435 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
_STLP_DECLSPEC complex< float > _STLP_CALL log10(const complex< float > &)
Definition: complex.cpp:230
calc_t calc
Definition: winmain.c:247

◆ rpn_not()

void rpn_not ( calc_number_t c)

Definition at line 280 of file fun_ieee.c.

281 {
282  if (calc.base == IDC_RADIO_DEC) {
284  n.i = logic_dbl2int(c);
285  c->f = (long double)(~n.i);
286  } else
287  c->i = ~c->i;
288 }
DWORD base
Definition: calc.h:189
#define IDC_RADIO_DEC
Definition: resource.h:22
GLdouble n
Definition: glext.h:7729
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
const GLubyte * c
Definition: glext.h:8905
__int64 logic_dbl2int(calc_number_t *a)
Definition: fun_ieee.c:261
calc_t calc
Definition: winmain.c:247

◆ rpn_pi()

void rpn_pi ( calc_number_t c)

Definition at line 290 of file fun_ieee.c.

291 {
292  c->f = CALC_PI;
293 }
const GLubyte * c
Definition: glext.h:8905
#define CALC_PI
Definition: calc.h:212

◆ rpn_reci()

void rpn_reci ( calc_number_t c)

Definition at line 216 of file fun_ieee.c.

217 {
218  if (c->f == 0)
219  calc.is_nan = TRUE;
220  else
221  c->f = 1./c->f;
222 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_s()

void rpn_s ( calc_number_t c)

Definition at line 553 of file fun_ieee.c.

554 {
555  rpn_s_ex(c, 0);
556 }
const GLubyte * c
Definition: glext.h:8905
static void rpn_s_ex(calc_number_t *c, int pop_type)
Definition: fun_ieee.c:519

◆ rpn_s_ex()

static void rpn_s_ex ( calc_number_t c,
int  pop_type 
)
static

Definition at line 519 of file fun_ieee.c.

520 {
521  double ave = 0;
522  double n = 0;
523  double dev = 0;
524  double num = 0;
525  statistic_t *p = calc.stat;
526 
527  ave = stat_sum();
529 
530  if (n == 0) {
531  c->f = 0;
532  return;
533  }
534  ave = ave / n;
535 
536  dev = 0;
537  p = calc.stat;
538  while (p != NULL) {
539  if (p->base == IDC_RADIO_DEC)
540  num = p->num.f;
541  else
542  num = (double)p->num.i;
543  dev += pow(num-ave, 2.);
544  p = (statistic_t *)(p->next);
545  }
546  dev = sqrt(dev/(pop_type ? n-1 : n));
547  if (calc.base == IDC_RADIO_DEC)
548  c->f = dev;
549  else
550  c->i = (__int64)dev;
551 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
statistic_t * stat
Definition: calc.h:181
DWORD base
Definition: calc.h:189
static double stat_sum(void)
Definition: fun_ieee.c:437
#define IDC_RADIO_DEC
Definition: resource.h:22
double f
Definition: calc.h:126
GLdouble n
Definition: glext.h:7729
#define SendDlgItemMessage
Definition: winuser.h:5708
static int dev
Definition: mkdosfs.c:536
float pow(float __x, int __y)
Definition: _cmath.h:458
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
#define LB_GETCOUNT
Definition: winuser.h:1999
const GLubyte * c
Definition: glext.h:8905
GLuint GLuint num
Definition: glext.h:9618
calc_number_t num
Definition: calc.h:155
HWND hStatWnd
Definition: calc.h:193
#define IDC_LIST_STAT
Definition: resource.h:96
GLfloat GLfloat p
Definition: glext.h:8902
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16

Referenced by rpn_s(), and rpn_s_m1().

◆ rpn_s_m1()

void rpn_s_m1 ( calc_number_t c)

Definition at line 558 of file fun_ieee.c.

559 {
560  rpn_s_ex(c, 1);
561 }
const GLubyte * c
Definition: glext.h:8905
static void rpn_s_ex(calc_number_t *c, int pop_type)
Definition: fun_ieee.c:519

◆ rpn_sign()

void rpn_sign ( calc_number_t c)

Definition at line 300 of file fun_ieee.c.

301 {
302  if (calc.base == IDC_RADIO_DEC)
303  c->f = 0-c->f;
304  else
305  c->i = 0-c->i;
306 }
DWORD base
Definition: calc.h:189
#define IDC_RADIO_DEC
Definition: resource.h:22
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_sin()

void rpn_sin ( calc_number_t c)

Definition at line 101 of file fun_ieee.c.

102 {
103  double angle = validate_angle2rad(c);
104 
105  if (angle == 0 || angle == CALC_PI)
106  c->f = 0;
107  else
108  if (angle == CALC_3_PI_2)
109  c->f = -1;
110  else
111  if (angle == CALC_2_PI)
112  c->f = 1;
113  else
114  c->f = sin(angle);
115 }
static double validate_angle2rad(calc_number_t *c)
Definition: fun_ieee.c:86
#define CALC_3_PI_2
Definition: calc.h:213
GLfloat angle
Definition: glext.h:10853
#define CALC_2_PI
Definition: calc.h:214
const GLubyte * c
Definition: glext.h:8905
#define CALC_PI
Definition: calc.h:212
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)

◆ rpn_sinh()

void rpn_sinh ( calc_number_t c)

Definition at line 163 of file fun_ieee.c.

164 {
165  c->f = sinh(c->f);
166  if (_isnan(c->f))
167  calc.is_nan = TRUE;
168 }
_STLP_DECLSPEC complex< float > _STLP_CALL sinh(const complex< float > &)
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_sqrt()

void rpn_sqrt ( calc_number_t c)

Definition at line 358 of file fun_ieee.c.

359 {
360  if (calc.base == IDC_RADIO_DEC) {
361  if (c->f < 0)
362  calc.is_nan = TRUE;
363  else
364  c->f = sqrt(c->f);
365  } else {
366  c->i = sqrti(c->i);
367  }
368 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
DWORD base
Definition: calc.h:189
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:22
BOOL is_nan
Definition: calc.h:183
const GLubyte * c
Definition: glext.h:8905
static unsigned __int64 sqrti(unsigned __int64 number)
Definition: fun_ieee.c:333
calc_t calc
Definition: winmain.c:247

◆ rpn_sum()

void rpn_sum ( calc_number_t c)

Definition at line 499 of file fun_ieee.c.

500 {
501  double sum = stat_sum();
502 
503  if (calc.base == IDC_RADIO_DEC)
504  c->f = sum;
505  else
506  c->i = (__int64)sum;
507 }
DWORD base
Definition: calc.h:189
static double stat_sum(void)
Definition: fun_ieee.c:437
#define IDC_RADIO_DEC
Definition: resource.h:22
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16

◆ rpn_sum2()

void rpn_sum2 ( calc_number_t c)

Definition at line 509 of file fun_ieee.c.

510 {
511  double sum = stat_sum2();
512 
513  if (calc.base == IDC_RADIO_DEC)
514  c->f = sum;
515  else
516  c->i = (__int64)sum;
517 }
DWORD base
Definition: calc.h:189
#define IDC_RADIO_DEC
Definition: resource.h:22
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
const GLubyte * c
Definition: glext.h:8905
static double stat_sum2(void)
Definition: fun_ieee.c:452
calc_t calc
Definition: winmain.c:247
#define __int64
Definition: basetyps.h:16

◆ rpn_tan()

void rpn_tan ( calc_number_t c)

Definition at line 131 of file fun_ieee.c.

132 {
133  double angle = validate_angle2rad(c);
134 
135  if (angle == CALC_PI_2 || angle == CALC_3_PI_2)
136  calc.is_nan = TRUE;
137  else
138  if (angle == CALC_PI || angle == CALC_2_PI)
139  c->f = 0;
140  else
141  c->f = tan(angle);
142 }
static double validate_angle2rad(calc_number_t *c)
Definition: fun_ieee.c:86
#define CALC_3_PI_2
Definition: calc.h:213
#define TRUE
Definition: types.h:120
GLfloat angle
Definition: glext.h:10853
BOOL is_nan
Definition: calc.h:183
#define CALC_2_PI
Definition: calc.h:214
#define CALC_PI_2
Definition: calc.h:211
const GLubyte * c
Definition: glext.h:8905
#define CALC_PI
Definition: calc.h:212
_STLP_DECLSPEC complex< float > _STLP_CALL tan(const complex< float > &)
calc_t calc
Definition: winmain.c:247

◆ rpn_tanh()

void rpn_tanh ( calc_number_t c)

Definition at line 175 of file fun_ieee.c.

176 {
177  c->f = tanh(c->f);
178  if (_isnan(c->f))
179  calc.is_nan = TRUE;
180 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
BOOL is_nan
Definition: calc.h:183
_STLP_DECLSPEC complex< float > _STLP_CALL tanh(const complex< float > &)
const GLubyte * c
Definition: glext.h:8905
calc_t calc
Definition: winmain.c:247

◆ rpn_zero()

void rpn_zero ( calc_number_t c)

Definition at line 586 of file fun_ieee.c.

587 {
588  c->f = 0;
589 }
const GLubyte * c
Definition: glext.h:8905

◆ sqrti()

static unsigned __int64 sqrti ( unsigned __int64  number)
static

Definition at line 333 of file fun_ieee.c.

334 {
335 /* modified form of Newton's method for approximating roots */
336 #define NEXT(n, i) (((n) + (i)/(n)) >> 1)
337  unsigned __int64 n, n1;
338 
339 #ifdef __GNUC__
340  if (number == 0xffffffffffffffffULL)
341 #else
342  if (number == 0xffffffffffffffffUI64)
343 #endif
344  return 0xffffffff;
345 
346  n = 1;
347  n1 = NEXT(n, number);
348  while (myabs64(n1 - n) > 1) {
349  n = n1;
350  n1 = NEXT(n, number);
351  }
352  while((n1*n1) > number)
353  n1--;
354  return n1;
355 #undef NEXT
356 }
#define NEXT(n, i)
GLdouble n
Definition: glext.h:7729
static size_t double number
Definition: printf.c:64
static __int64 myabs64(__int64 number)
Definition: fun_ieee.c:328
int n1
Definition: dwarfget.c:148
#define __int64
Definition: basetyps.h:16

Referenced by rpn_sqrt().

◆ stat_sum()

static double stat_sum ( void  )
static

Definition at line 437 of file fun_ieee.c.

438 {
439  double sum = 0;
440  statistic_t *p = calc.stat;
441 
442  while (p != NULL) {
443  if (p->base == IDC_RADIO_DEC)
444  sum += p->num.f;
445  else
446  sum += p->num.i;
447  p = (statistic_t *)(p->next);
448  }
449  return sum;
450 }
statistic_t * stat
Definition: calc.h:181
#define IDC_RADIO_DEC
Definition: resource.h:22
smooth NULL
Definition: ftsmooth.c:416
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
GLfloat GLfloat p
Definition: glext.h:8902
calc_t calc
Definition: winmain.c:247

Referenced by rpn_ave(), rpn_s_ex(), and rpn_sum().

◆ stat_sum2()

static double stat_sum2 ( void  )
static

Definition at line 452 of file fun_ieee.c.

453 {
454  double sum = 0;
455  statistic_t *p = calc.stat;
456 
457  while (p != NULL) {
458  if (p->base == IDC_RADIO_DEC)
459  sum += p->num.f * p->num.f;
460  else
461  sum += (double)p->num.i * (double)p->num.i;
462  p = (statistic_t *)(p->next);
463  }
464  return sum;
465 }
statistic_t * stat
Definition: calc.h:181
#define IDC_RADIO_DEC
Definition: resource.h:22
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
smooth NULL
Definition: ftsmooth.c:416
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
GLfloat GLfloat p
Definition: glext.h:8902
calc_t calc
Definition: winmain.c:247

Referenced by rpn_ave2(), and rpn_sum2().

◆ validate_angle2rad()

static double validate_angle2rad ( calc_number_t c)
static

Definition at line 86 of file fun_ieee.c.

87 {
88  switch (calc.degr) {
89  case IDC_RADIO_DEG:
90  c->f = c->f * (CALC_PI/180.0);
91  break;
92  case IDC_RADIO_RAD:
93  break;
94  case IDC_RADIO_GRAD:
95  c->f = c->f * (CALC_PI/200.0);
96  break;
97  }
98  return c->f;
99 }
#define IDC_RADIO_DEG
Definition: resource.h:86
#define IDC_RADIO_GRAD
Definition: resource.h:88
DWORD degr
Definition: calc.h:191
const GLubyte * c
Definition: glext.h:8905
#define CALC_PI
Definition: calc.h:212
#define IDC_RADIO_RAD
Definition: resource.h:87
calc_t calc
Definition: winmain.c:247

Referenced by rpn_cos(), rpn_sin(), and rpn_tan().

◆ validate_rad2angle()

static double validate_rad2angle ( double  a)
static

Definition at line 71 of file fun_ieee.c.

72 {
73  switch (calc.degr) {
74  case IDC_RADIO_DEG:
75  a = a * (180.0/CALC_PI);
76  break;
77  case IDC_RADIO_RAD:
78  break;
79  case IDC_RADIO_GRAD:
80  a = a * (200.0/CALC_PI);
81  break;
82  }
83  return a;
84 }
#define IDC_RADIO_DEG
Definition: resource.h:86
#define IDC_RADIO_GRAD
Definition: resource.h:88
DWORD degr
Definition: calc.h:191
#define a
Definition: ke_i.h:78
#define CALC_PI
Definition: calc.h:212
#define IDC_RADIO_RAD
Definition: resource.h:87
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:247

Referenced by rpn_acos(), rpn_asin(), and rpn_atan().