ReactOS  0.4.12-dev-102-g4b7f1e0
function.c File Reference
#include "calc.h"
#include <limits.h>
Include dependency graph for function.c:

Go to the source code of this file.

Macros

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

Functions

void apply_int_mask (calc_number_t *r)
 
double asinh (double x)
 
double acosh (double x)
 
double atanh (double x)
 
double validate_rad2angle (double a)
 
double validate_angle2rad (calc_number_t *c)
 
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)
 
void rpn_ave (calc_number_t *c)
 
void rpn_sum (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)

Referenced by sqrti().

Function Documentation

◆ acosh()

double acosh ( double  x)

Definition at line 33 of file function.c.

Referenced by rpn_acosh().

34 {
35  // must be x>=1, if not return Nan (Not a Number)
36  if(!(x>=1.0)) return sqrt(-1.0);
37 
38  // return only the positive result (as sqrt does).
39  return log(x+sqrt(x*x-1.0));
40 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
INT x
Definition: msvc.h:62
#define log(outFile, fmt,...)
Definition: util.h:15

◆ apply_int_mask()

void apply_int_mask ( calc_number_t r)

Definition at line 5 of file function.c.

Referenced by convert_real_integer(), DlgMainProc(), run_operator(), and upload_stat_number().

6 {
7  unsigned __int64 mask;
8 
9  switch (calc.size) {
10  case IDC_RADIO_QWORD:
11  mask = _UI64_MAX;
12  break;
13  case IDC_RADIO_DWORD:
14  mask = ULONG_MAX;
15  break;
16  case IDC_RADIO_WORD:
17  mask = USHRT_MAX;
18  break;
19  case IDC_RADIO_BYTE:
20  mask = UCHAR_MAX;
21  break;
22  default:
23  mask = (unsigned __int64)-1;
24  }
25  r->i &= mask;
26 }
#define _UI64_MAX
Definition: limits.h:63
#define IDC_RADIO_WORD
Definition: resource.h:79
GLuint const GLubyte mask[]
Definition: s_context.h:57
#define USHRT_MAX
Definition: limits.h:38
#define IDC_RADIO_QWORD
Definition: resource.h:77
DWORD size
Definition: calc.h:139
INT64 i
Definition: calc.h:78
#define UCHAR_MAX
Definition: limits.h:25
#define IDC_RADIO_DWORD
Definition: resource.h:78
calc_t calc
Definition: winmain.c:226
#define ULONG_MAX
Definition: limits.h:44
#define __int64
Definition: basetyps.h:16
#define IDC_RADIO_BYTE
Definition: resource.h:80

◆ asinh()

double asinh ( double  x)

Definition at line 28 of file function.c.

Referenced by rpn_asinh().

29 {
30  return log(x+sqrt(x*x+1));
31 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
INT x
Definition: msvc.h:62
#define log(outFile, fmt,...)
Definition: util.h:15

◆ atanh()

double atanh ( double  x)

Definition at line 42 of file function.c.

Referenced by rpn_atanh().

43 {
44  // must be x>-1, x<1, if not return Nan (Not a Number)
45  if(!(x>-1.0 && x<1.0)) return sqrt(-1.0);
46 
47  return log((1.0+x)/(1.0-x))/2.0;
48 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
INT x
Definition: msvc.h:62
#define log(outFile, fmt,...)
Definition: util.h:15

◆ cbrti()

static __int64 cbrti ( __int64  x)
static

Definition at line 348 of file function.c.

Referenced by rpn_cbrt().

348  {
349  __int64 s, y, b;
350 
351  s = 60;
352  y = 0;
353  while(s >= 0) {
354  y = 2*y;
355  b = (3*y*(y + 1) + 1) << s;
356  s = s - 3;
357  if (x >= b) {
358  x = x - b;
359  y = y + 1;
360  }
361  }
362  return y;
363 }
INT INT y
Definition: msvc.h:62
#define b
Definition: ke_i.h:79
GLdouble s
Definition: gl.h:2039
INT x
Definition: msvc.h:62
#define __int64
Definition: basetyps.h:16

◆ logic_dbl2int()

__int64 logic_dbl2int ( calc_number_t a)

Definition at line 240 of file function.c.

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

241 {
242  double int_part;
243  int width;
244 
245  modf(a->f, &int_part);
246  width = (int_part==0) ? 1 : (int)log10(fabs(int_part))+1;
247  if (width > 63) {
248  calc.is_nan = TRUE;
249  return 0;
250  }
251  return (__int64)int_part;
252 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
_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)
calc_t calc
Definition: winmain.c:226
#define __int64
Definition: basetyps.h:16
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ logic_int2dbl()

double logic_int2dbl ( calc_number_t a)

Definition at line 253 of file function.c.

Referenced by run_operator().

254 {
255  return (double)a->i;
256 }
INT64 i
Definition: calc.h:78

◆ myabs64()

static __int64 myabs64 ( __int64  number)
static

Definition at line 306 of file function.c.

Referenced by sqrti().

307 {
308  return (number < 0) ? 0-number : number;
309 }
static size_t double number
Definition: printf.c:64

◆ rpn_2pi()

void rpn_2pi ( calc_number_t c)

Definition at line 273 of file function.c.

274 {
275  c->f = CALC_PI*2;
276 }
double f
Definition: calc.h:77
#define CALC_PI
Definition: calc.h:161

◆ rpn_acos()

void rpn_acos ( calc_number_t c)

Definition at line 129 of file function.c.

130 {
131  c->f = validate_rad2angle(acos(c->f));
132  if (_isnan(c->f))
133  calc.is_nan = TRUE;
134 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double validate_rad2angle(double a)
Definition: function.c:50
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
valarray< _Tp > acos(const valarray< _Tp > &__x)
Definition: _valarray.h:901
calc_t calc
Definition: winmain.c:226

◆ rpn_acosh()

void rpn_acosh ( calc_number_t c)

Definition at line 167 of file function.c.

168 {
169  c->f = acosh(c->f);
170  if (_isnan(c->f))
171  calc.is_nan = TRUE;
172 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
double acosh(double x)
Definition: function.c:33
calc_t calc
Definition: winmain.c:226

◆ rpn_alloc()

void rpn_alloc ( calc_number_t c)

Definition at line 538 of file function.c.

Referenced by exec_closeparent(), and run_dat_sta().

539 {
540 }

◆ rpn_asin()

void rpn_asin ( calc_number_t c)

Definition at line 123 of file function.c.

124 {
125  c->f = validate_rad2angle(asin(c->f));
126  if (_isnan(c->f))
127  calc.is_nan = TRUE;
128 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double validate_rad2angle(double a)
Definition: function.c:50
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
valarray< _Tp > asin(const valarray< _Tp > &__x)
Definition: _valarray.h:910
calc_t calc
Definition: winmain.c:226

◆ rpn_asinh()

void rpn_asinh ( calc_number_t c)

Definition at line 161 of file function.c.

162 {
163  c->f = asinh(c->f);
164  if (_isnan(c->f))
165  calc.is_nan = TRUE;
166 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double asinh(double x)
Definition: function.c:28
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_atan()

void rpn_atan ( calc_number_t c)

Definition at line 135 of file function.c.

136 {
137  c->f = validate_rad2angle(atan(c->f));
138  if (_isnan(c->f))
139  calc.is_nan = TRUE;
140 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double validate_rad2angle(double a)
Definition: function.c:50
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
valarray< _Tp > atan(const valarray< _Tp > &__x)
Definition: _valarray.h:919
calc_t calc
Definition: winmain.c:226

◆ rpn_atanh()

void rpn_atanh ( calc_number_t c)

Definition at line 173 of file function.c.

174 {
175  c->f = atanh(c->f);
176  if (_isnan(c->f))
177  calc.is_nan = TRUE;
178 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double f
Definition: calc.h:77
double atanh(double x)
Definition: function.c:42
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_ave()

void rpn_ave ( calc_number_t c)

Definition at line 430 of file function.c.

431 {
432  double ave = 0;
433  int n;
434 
435  ave = stat_sum();
437 
438  if (n)
439  ave = ave / (double)n;
440  if (calc.base == IDC_RADIO_DEC)
441  c->f = ave;
442  else
443  c->i = (__int64)ave;
444 }
DWORD base
Definition: calc.h:138
static double stat_sum(void)
Definition: function.c:415
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
#define SendDlgItemMessage
Definition: winuser.h:5708
GLuint n
Definition: s_context.h:57
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
INT64 i
Definition: calc.h:78
HWND hStatWnd
Definition: calc.h:142
#define IDC_LIST_STAT
Definition: resource.h:90
calc_t calc
Definition: winmain.c:226
#define __int64
Definition: basetyps.h:16

◆ rpn_cbrt()

void rpn_cbrt ( calc_number_t c)

Definition at line 365 of file function.c.

366 {
367  if (calc.base == IDC_RADIO_DEC)
368 #if defined(__GNUC__) && !defined(__REACTOS__)
369  c->f = cbrt(c->f);
370 #else
371  c->f = pow(c->f,1./3.);
372 #endif
373  else {
374  c->i = cbrti(c->i);
375  }
376 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
double __cdecl cbrt(double)
float pow(float __x, int __y)
Definition: _cmath.h:458
INT64 i
Definition: calc.h:78
static __int64 cbrti(__int64 x)
Definition: function.c:348
calc_t calc
Definition: winmain.c:226

◆ rpn_copy()

void rpn_copy ( calc_number_t dst,
calc_number_t src 
)

Definition at line 528 of file function.c.

Referenced by convert_text2number(), DlgMainProc(), evalStack(), exec_closeparent(), exec_infix2postfix(), run_dat_sta(), run_ms(), run_mw(), and upload_stat_number().

529 {
530  *dst = *src;
531 }
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57

◆ rpn_cos()

void rpn_cos ( calc_number_t c)

Definition at line 95 of file function.c.

96 {
97  double angle = validate_angle2rad(c);
98 
99  if (angle == CALC_PI_2 || angle == CALC_3_PI_2)
100  c->f = 0;
101  else
102  if (angle == CALC_PI)
103  c->f = -1;
104  else
105  if (angle == CALC_2_PI)
106  c->f = 1;
107  else
108  c->f = cos(angle);
109 }
#define CALC_3_PI_2
Definition: calc.h:162
double f
Definition: calc.h:77
GLfloat angle
Definition: glext.h:10853
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
#define CALC_2_PI
Definition: calc.h:163
#define CALC_PI_2
Definition: calc.h:160
double validate_angle2rad(calc_number_t *c)
Definition: function.c:65
#define CALC_PI
Definition: calc.h:161

◆ rpn_cosh()

void rpn_cosh ( calc_number_t c)

Definition at line 148 of file function.c.

149 {
150  c->f = cosh(c->f);
151  if (_isnan(c->f))
152  calc.is_nan = TRUE;
153 }
#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 > &)
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_dec2dms()

void rpn_dec2dms ( calc_number_t c)

Definition at line 514 of file function.c.

515 {
516  double d, m, s;
517 
518  m = modf(c->f, &d) * 60;
519  s = ceil(modf(m, &m) * 60);
520  c->f = d + m/100. + s/10000.;
521 }
_Check_return_ _CRTIMP double __cdecl ceil(_In_ double x)
double f
Definition: calc.h:77
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039
CONST GLfloat m[16]
Definition: m_xform.h:144
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_dms2dec()

void rpn_dms2dec ( calc_number_t c)

Definition at line 500 of file function.c.

501 {
502  double d, m, s;
503 
504  m = modf(c->f, &d) * 100;
505  s = (modf(m, &m) * 100)+.5;
506  modf(s, &s);
507 
508  m = m/60;
509  s = s/3600;
510 
511  c->f = d + m + s;
512 }
double f
Definition: calc.h:77
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039
CONST GLfloat m[16]
Definition: m_xform.h:144
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_exp()

void rpn_exp ( calc_number_t c)

Definition at line 378 of file function.c.

379 {
380  c->f = exp(c->f);
381  if (_finite(c->f) == 0)
382  calc.is_nan = TRUE;
383 }
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
DWORD exp
Definition: msg.c:15681
calc_t calc
Definition: winmain.c:226

◆ rpn_exp10()

void rpn_exp10 ( calc_number_t c)

Definition at line 385 of file function.c.

386 {
387  double int_part;
388 
389  modf(c->f, &int_part);
390  if (fmod(int_part, 2.) == 0.)
391  calc.is_nan = TRUE;
392  else {
393  c->f = pow(10., c->f);
394  if (_finite(c->f) == 0)
395  calc.is_nan = TRUE;
396  }
397 }
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
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)
calc_t calc
Definition: winmain.c:226
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_exp2()

void rpn_exp2 ( calc_number_t c)

Definition at line 286 of file function.c.

287 {
288  if (calc.base == IDC_RADIO_DEC) {
289  c->f *= c->f;
290  if (_finite(c->f) == 0)
291  calc.is_nan = TRUE;
292  } else
293  c->i *= c->i;
294 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
INT64 i
Definition: calc.h:78
calc_t calc
Definition: winmain.c:226

◆ rpn_exp3()

void rpn_exp3 ( calc_number_t c)

Definition at line 296 of file function.c.

297 {
298  if (calc.base == IDC_RADIO_DEC) {
299  c->f = pow(c->f, 3.);
300  if (_finite(c->f) == 0)
301  calc.is_nan = TRUE;
302  } else
303  c->i *= (c->i*c->i);
304 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
float pow(float __x, int __y)
Definition: _cmath.h:458
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
INT64 i
Definition: calc.h:78
calc_t calc
Definition: winmain.c:226

◆ rpn_fact()

void rpn_fact ( calc_number_t c)

Definition at line 203 of file function.c.

204 {
205  double fact, mult, num;
206 
207  if (calc.base == IDC_RADIO_DEC)
208  num = c->f;
209  else
210  num = (double)c->i;
211  if (num > 1000) {
212  calc.is_nan = TRUE;
213  return;
214  }
215  if (num < 0) {
216  calc.is_nan = TRUE;
217  return;
218  } else
219  if (num == 0)
220  fact = 1;
221  else {
222  rpn_int(c);
223  fact = 1;
224  mult = 2;
225  while (mult <= num) {
226  fact *= mult;
227  mult++;
228  }
229  c->f = fact;
230  }
231  if (_finite(fact) == 0)
232  calc.is_nan = TRUE;
233  else
234  if (calc.base == IDC_RADIO_DEC)
235  c->f = fact;
236  else
237  c->i = (__int64)fact;
238 }
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
void rpn_int(calc_number_t *c)
Definition: function.c:180
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:717
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
INT64 i
Definition: calc.h:78
GLuint GLuint num
Definition: glext.h:9618
calc_t calc
Definition: winmain.c:226
#define __int64
Definition: basetyps.h:16

◆ rpn_frac()

void rpn_frac ( calc_number_t c)

Definition at line 188 of file function.c.

189 {
190  double int_part;
191 
192  c->f = modf(calc.code.f, &int_part);
193 }
calc_number_t code
Definition: calc.h:127
double f
Definition: calc.h:77
calc_t calc
Definition: winmain.c:226
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_free()

void rpn_free ( calc_number_t c)

Definition at line 542 of file function.c.

Referenced by clean_stat_list(), delete_stat_item(), and exec_closeparent().

543 {
544 }

◆ rpn_int()

void rpn_int ( calc_number_t c)

Definition at line 180 of file function.c.

Referenced by rpn_fact().

181 {
182  double int_part;
183 
184  modf(calc.code.f, &int_part);
185  c->f = int_part;
186 }
calc_number_t code
Definition: calc.h:127
double f
Definition: calc.h:77
calc_t calc
Definition: winmain.c:226
_Check_return_ _CRTIMP double __cdecl modf(_In_ double x, _Out_ double *y)

◆ rpn_is_zero()

int rpn_is_zero ( calc_number_t c)

Definition at line 533 of file function.c.

Referenced by prepare_rpn_result_2(), run_ms(), and run_mw().

534 {
535  return (c->f == 0);
536 }
double f
Definition: calc.h:77

◆ rpn_ln()

void rpn_ln ( calc_number_t c)

Definition at line 399 of file function.c.

400 {
401  if (c->f <= 0)
402  calc.is_nan = TRUE;
403  else
404  c->f = log(c->f);
405 }
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226
#define log(outFile, fmt,...)
Definition: util.h:15

◆ rpn_log()

void rpn_log ( calc_number_t c)

Definition at line 407 of file function.c.

408 {
409  if (c->f <= 0)
410  calc.is_nan = TRUE;
411  else
412  c->f = log10(c->f);
413 }
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
_STLP_DECLSPEC complex< float > _STLP_CALL log10(const complex< float > &)
Definition: complex.cpp:230
calc_t calc
Definition: winmain.c:226

◆ rpn_not()

void rpn_not ( calc_number_t c)

Definition at line 258 of file function.c.

259 {
260  if (calc.base == IDC_RADIO_DEC) {
262  n.i = logic_dbl2int(c);
263  c->f = (long double)(~n.i);
264  } else
265  c->i = ~c->i;
266 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
GLuint n
Definition: s_context.h:57
__int64 logic_dbl2int(calc_number_t *a)
Definition: function.c:240
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
INT64 i
Definition: calc.h:78
calc_t calc
Definition: winmain.c:226

◆ rpn_pi()

void rpn_pi ( calc_number_t c)

Definition at line 268 of file function.c.

269 {
270  c->f = CALC_PI;
271 }
double f
Definition: calc.h:77
#define CALC_PI
Definition: calc.h:161

◆ rpn_reci()

void rpn_reci ( calc_number_t c)

Definition at line 195 of file function.c.

196 {
197  if (c->f == 0)
198  calc.is_nan = TRUE;
199  else
200  c->f = 1./c->f;
201 }
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_s()

void rpn_s ( calc_number_t c)

Definition at line 490 of file function.c.

491 {
492  rpn_s_ex(c, 0);
493 }
static void rpn_s_ex(calc_number_t *c, int pop_type)
Definition: function.c:456

◆ rpn_s_ex()

static void rpn_s_ex ( calc_number_t c,
int  pop_type 
)
static

Definition at line 456 of file function.c.

Referenced by rpn_s(), and rpn_s_m1().

457 {
458  double ave = 0;
459  double n = 0;
460  double dev = 0;
461  double num = 0;
462  statistic_t *p = calc.stat;
463 
464  ave = stat_sum();
466 
467  if (n == 0) {
468  c->f = 0;
469  return;
470  }
471  ave = ave / n;
472 
473  dev = 0;
474  p = calc.stat;
475  while (p != NULL) {
476  if (p->base == IDC_RADIO_DEC)
477  num = p->num.f;
478  else
479  num = (double)p->num.i;
480  dev += pow(num-ave, 2.);
481  p = (statistic_t *)(p->next);
482  }
483  dev = sqrt(dev/(pop_type ? n-1 : n));
484  if (calc.base == IDC_RADIO_DEC)
485  c->f = dev;
486  else
487  c->i = (__int64)dev;
488 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
statistic_t * stat
Definition: calc.h:130
DWORD base
Definition: calc.h:138
static double stat_sum(void)
Definition: function.c:415
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
#define SendDlgItemMessage
Definition: winuser.h:5708
static int dev
Definition: mkdosfs.c:536
GLuint n
Definition: s_context.h:57
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
void * next
Definition: calc.h:108
INT64 i
Definition: calc.h:78
GLuint GLuint num
Definition: glext.h:9618
DWORD base
Definition: calc.h:107
calc_number_t num
Definition: calc.h:106
HWND hStatWnd
Definition: calc.h:142
#define IDC_LIST_STAT
Definition: resource.h:90
GLfloat GLfloat p
Definition: glext.h:8902
calc_t calc
Definition: winmain.c:226
#define __int64
Definition: basetyps.h:16

◆ rpn_s_m1()

void rpn_s_m1 ( calc_number_t c)

Definition at line 495 of file function.c.

496 {
497  rpn_s_ex(c, 1);
498 }
static void rpn_s_ex(calc_number_t *c, int pop_type)
Definition: function.c:456

◆ rpn_sign()

void rpn_sign ( calc_number_t c)

Definition at line 278 of file function.c.

Referenced by DlgMainProc().

279 {
280  if (calc.base == IDC_RADIO_DEC)
281  c->f = 0-c->f;
282  else
283  c->i = 0-c->i;
284 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
INT64 i
Definition: calc.h:78
calc_t calc
Definition: winmain.c:226

◆ rpn_sin()

void rpn_sin ( calc_number_t c)

Definition at line 80 of file function.c.

81 {
82  double angle = validate_angle2rad(c);
83 
84  if (angle == 0 || angle == CALC_PI)
85  c->f = 0;
86  else
87  if (angle == CALC_3_PI_2)
88  c->f = -1;
89  else
90  if (angle == CALC_2_PI)
91  c->f = 1;
92  else
93  c->f = sin(angle);
94 }
#define CALC_3_PI_2
Definition: calc.h:162
double f
Definition: calc.h:77
GLfloat angle
Definition: glext.h:10853
#define CALC_2_PI
Definition: calc.h:163
double validate_angle2rad(calc_number_t *c)
Definition: function.c:65
#define CALC_PI
Definition: calc.h:161
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)

◆ rpn_sinh()

void rpn_sinh ( calc_number_t c)

Definition at line 142 of file function.c.

143 {
144  c->f = sinh(c->f);
145  if (_isnan(c->f))
146  calc.is_nan = TRUE;
147 }
_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)
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_sqrt()

void rpn_sqrt ( calc_number_t c)

Definition at line 336 of file function.c.

337 {
338  if (calc.base == IDC_RADIO_DEC) {
339  if (c->f < 0)
340  calc.is_nan = TRUE;
341  else
342  c->f = sqrt(c->f);
343  } else {
344  c->i = sqrti(c->i);
345  }
346 }
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Definition: complex.cpp:188
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
INT64 i
Definition: calc.h:78
static unsigned __int64 sqrti(unsigned __int64 number)
Definition: function.c:311
calc_t calc
Definition: winmain.c:226

◆ rpn_sum()

void rpn_sum ( calc_number_t c)

Definition at line 446 of file function.c.

447 {
448  double sum = stat_sum();
449 
450  if (calc.base == IDC_RADIO_DEC)
451  c->f = sum;
452  else
453  c->i = (__int64)sum;
454 }
DWORD base
Definition: calc.h:138
static double stat_sum(void)
Definition: function.c:415
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
INT64 i
Definition: calc.h:78
calc_t calc
Definition: winmain.c:226
#define __int64
Definition: basetyps.h:16

◆ rpn_tan()

void rpn_tan ( calc_number_t c)

Definition at line 110 of file function.c.

111 {
112  double angle = validate_angle2rad(c);
113 
114  if (angle == CALC_PI_2 || angle == CALC_3_PI_2)
115  calc.is_nan = TRUE;
116  else
117  if (angle == CALC_PI || angle == CALC_2_PI)
118  c->f = 0;
119  else
120  c->f = tan(angle);
121 }
#define CALC_3_PI_2
Definition: calc.h:162
#define TRUE
Definition: types.h:120
double f
Definition: calc.h:77
GLfloat angle
Definition: glext.h:10853
BOOL is_nan
Definition: calc.h:132
#define CALC_2_PI
Definition: calc.h:163
#define CALC_PI_2
Definition: calc.h:160
double validate_angle2rad(calc_number_t *c)
Definition: function.c:65
#define CALC_PI
Definition: calc.h:161
_STLP_DECLSPEC complex< float > _STLP_CALL tan(const complex< float > &)
calc_t calc
Definition: winmain.c:226

◆ rpn_tanh()

void rpn_tanh ( calc_number_t c)

Definition at line 154 of file function.c.

155 {
156  c->f = tanh(c->f);
157  if (_isnan(c->f))
158  calc.is_nan = TRUE;
159 }
#define TRUE
Definition: types.h:120
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _isnan(_In_ double)
double f
Definition: calc.h:77
BOOL is_nan
Definition: calc.h:132
_STLP_DECLSPEC complex< float > _STLP_CALL tanh(const complex< float > &)
calc_t calc
Definition: winmain.c:226

◆ rpn_zero()

void rpn_zero ( calc_number_t c)

Definition at line 523 of file function.c.

Referenced by convert_text2number(), DlgMainProc(), prepare_rpn_result(), run_canc(), and start_rpn_engine().

524 {
525  c->f = 0;
526 }
double f
Definition: calc.h:77

◆ sqrti()

static unsigned __int64 sqrti ( unsigned __int64  number)
static

Definition at line 311 of file function.c.

Referenced by rpn_sqrt().

312 {
313 /* modified form of Newton's method for approximating roots */
314 #define NEXT(n, i) (((n) + (i)/(n)) >> 1)
315  unsigned __int64 n, n1;
316 
317 #ifdef __GNUC__
318  if (number == 0xffffffffffffffffLL)
319 #else
320  if (number == 0xffffffffffffffff)
321 #endif
322  return 0xffffffff;
323 
324  n = 1;
325  n1 = NEXT(n, number);
326  while (myabs64(n1 - n) > 1) {
327  n = n1;
328  n1 = NEXT(n, number);
329  }
330  while((n1*n1) > number)
331  n1--;
332  return n1;
333 #undef NEXT
334 }
#define NEXT(n, i)
GLuint n
Definition: s_context.h:57
static size_t double number
Definition: printf.c:64
int n1
Definition: dwarfget.c:148
static __int64 myabs64(__int64 number)
Definition: function.c:306
#define __int64
Definition: basetyps.h:16

◆ stat_sum()

static double stat_sum ( void  )
static

Definition at line 415 of file function.c.

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

416 {
417  double sum = 0;
418  statistic_t *p = calc.stat;
419 
420  while (p != NULL) {
421  if (p->base == IDC_RADIO_DEC)
422  sum += p->num.f;
423  else
424  sum += p->num.i;
425  p = (statistic_t *)(p->next);
426  }
427  return sum;
428 }
statistic_t * stat
Definition: calc.h:130
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
smooth NULL
Definition: ftsmooth.c:416
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
void * next
Definition: calc.h:108
INT64 i
Definition: calc.h:78
DWORD base
Definition: calc.h:107
calc_number_t num
Definition: calc.h:106
GLfloat GLfloat p
Definition: glext.h:8902
calc_t calc
Definition: winmain.c:226

◆ validate_angle2rad()

double validate_angle2rad ( calc_number_t c)

Definition at line 65 of file function.c.

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

66 {
67  switch (calc.degr) {
68  case IDC_RADIO_DEG:
69  c->f = c->f * (CALC_PI/180.0);
70  break;
71  case IDC_RADIO_RAD:
72  break;
73  case IDC_RADIO_GRAD:
74  c->f = c->f * (CALC_PI/200.0);
75  break;
76  }
77  return c->f;
78 }
#define IDC_RADIO_DEG
Definition: resource.h:81
#define IDC_RADIO_GRAD
Definition: resource.h:83
double f
Definition: calc.h:77
DWORD degr
Definition: calc.h:140
#define CALC_PI
Definition: calc.h:161
#define IDC_RADIO_RAD
Definition: resource.h:82
calc_t calc
Definition: winmain.c:226

◆ validate_rad2angle()

double validate_rad2angle ( double  a)

Definition at line 50 of file function.c.

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

51 {
52  switch (calc.degr) {
53  case IDC_RADIO_DEG:
54  a = a * (180.0/CALC_PI);
55  break;
56  case IDC_RADIO_RAD:
57  break;
58  case IDC_RADIO_GRAD:
59  a = a * (200.0/CALC_PI);
60  break;
61  }
62  return a;
63 }
#define IDC_RADIO_DEG
Definition: resource.h:81
#define IDC_RADIO_GRAD
Definition: resource.h:83
DWORD degr
Definition: calc.h:140
#define a
Definition: ke_i.h:78
#define CALC_PI
Definition: calc.h:161
#define IDC_RADIO_RAD
Definition: resource.h:82
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
calc_t calc
Definition: winmain.c:226