ReactOS  0.4.12-dev-18-gf469aca
calc.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winuser.h>
#include <tchar.h>
#include <math.h>
#include <float.h>
#include <malloc.h>
#include <htmlhelp.h>
#include "resource.h"
Include dependency graph for calc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  calc_number_t
 
struct  calc_node_t
 
struct  sequence_t
 
struct  statistic_t
 
struct  calc_t
 

Macros

#define WM_CLOSE_STATS   (WM_APP+1)
 
#define WM_HANDLE_CLIPBOARD   (WM_APP+2)
 
#define WM_INSERT_STAT   (WM_APP+3)
 
#define WM_LOAD_STAT   (WM_APP+4)
 
#define WM_START_CONV   (WM_APP+5)
 
#define WM_HANDLE_FROM   (WM_APP+6)
 
#define WM_HANDLE_TO   (WM_APP+7)
 
#define LOCAL_EXP_SIZE   10000L
 
#define IDC_STATIC   ((DWORD)-1)
 
#define MAX_CALC_SIZE   256
 
#define SIZEOF(_ar)   (sizeof(_ar)/sizeof(_ar[1]))
 
#define CALC_E   2.7182818284590452354
 
#define CALC_PI_2   1.57079632679489661923
 
#define CALC_PI   3.14159265358979323846
 
#define CALC_3_PI_2   4.71238898038468985769
 
#define CALC_2_PI   6.283185307179586476925
 
#define MODIFIER_INV   0x01
 
#define MODIFIER_HYP   0x02
 
#define NO_CHAIN   0x04
 

Enumerations

enum  {
  RPN_OPERATOR_PARENT, RPN_OPERATOR_PERCENT, RPN_OPERATOR_EQUAL, RPN_OPERATOR_OR,
  RPN_OPERATOR_XOR, RPN_OPERATOR_AND, RPN_OPERATOR_LSH, RPN_OPERATOR_RSH,
  RPN_OPERATOR_ADD, RPN_OPERATOR_SUB, RPN_OPERATOR_MULT, RPN_OPERATOR_DIV,
  RPN_OPERATOR_MOD, RPN_OPERATOR_POW, RPN_OPERATOR_SQR, RPN_OPERATOR_NONE
}
 
enum  { CALC_LAYOUT_SCIENTIFIC =0, CALC_LAYOUT_STANDARD, CALC_LAYOUT_CONVERSION }
 

Functions

void run_operator (calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
 
int exec_infix2postfix (calc_number_t *, unsigned int)
 
void exec_closeparent (calc_number_t *)
 
int eval_parent_count (void)
 
void flush_postfix (void)
 
void exec_change_infix (void)
 
void start_rpn_engine (void)
 
void stop_rpn_engine (void)
 
void apply_int_mask (calc_number_t *a)
 
__int64 logic_dbl2int (calc_number_t *a)
 
double logic_int2dbl (calc_number_t *a)
 
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)
 
BOOL rpn_validate_result (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)
 
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)
 
void rpn_sqrt (calc_number_t *c)
 
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)
 
void rpn_ave (calc_number_t *c)
 
void rpn_sum (calc_number_t *c)
 
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)
 
void prepare_rpn_result_2 (calc_number_t *rpn, TCHAR *buffer, int size, int base)
 
void convert_text2number_2 (calc_number_t *a)
 
void convert_real_integer (unsigned int base)
 
INT_PTR CALLBACK AboutDlgProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
 
void ConvExecute (HWND hWnd)
 
void ConvAdjust (HWND hWnd, int n_cat)
 
void ConvInit (HWND hWnd)
 

Variables

calc_t calc
 

Macro Definition Documentation

◆ CALC_2_PI

#define CALC_2_PI   6.283185307179586476925

Definition at line 163 of file calc.h.

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

◆ CALC_3_PI_2

#define CALC_3_PI_2   4.71238898038468985769

Definition at line 162 of file calc.h.

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

◆ CALC_E

#define CALC_E   2.7182818284590452354

Definition at line 158 of file calc.h.

◆ CALC_PI

#define CALC_PI   3.14159265358979323846

Definition at line 161 of file calc.h.

Referenced by rpn_2pi(), rpn_cos(), rpn_pi(), rpn_sin(), rpn_tan(), validate_angle2rad(), and validate_rad2angle().

◆ CALC_PI_2

#define CALC_PI_2   1.57079632679489661923

Definition at line 160 of file calc.h.

Referenced by rpn_cos(), and rpn_tan().

◆ IDC_STATIC

#define IDC_STATIC   ((DWORD)-1)

Definition at line 41 of file calc.h.

Referenced by _tWinMain(), build_operand(), DlgMainProc(), EventDetails(), and OSK_DlgProc().

◆ LOCAL_EXP_SIZE

#define LOCAL_EXP_SIZE   10000L

Definition at line 34 of file calc.h.

Referenced by build_operand().

◆ MAX_CALC_SIZE

#define MAX_CALC_SIZE   256

Definition at line 44 of file calc.h.

◆ MODIFIER_HYP

#define MODIFIER_HYP   0x02

Definition at line 166 of file calc.h.

Referenced by DlgMainProc(), and get_modifiers().

◆ MODIFIER_INV

#define MODIFIER_INV   0x01

Definition at line 165 of file calc.h.

Referenced by DlgMainProc(), and get_modifiers().

◆ NO_CHAIN

#define NO_CHAIN   0x04

Definition at line 167 of file calc.h.

Referenced by DlgMainProc().

◆ SIZEOF

#define SIZEOF (   _ar)    (sizeof(_ar)/sizeof(_ar[1]))

Definition at line 48 of file calc.h.

Referenced by _tWinMain(), access_virt_barray(), access_virt_sarray(), add_huff_table(), alloc_barray(), alloc_large(), alloc_sarray(), alloc_small(), build_bg_ycc_rgb_table(), build_operand(), build_rgb_y_table(), build_signature_table_name(), build_ycc_rgb_table(), compress_data(), ConvAdjust(), ConvExecute(), ConvInit(), create_qualifier_enum(), create_signature(), decompress_onepass(), display_rpn_result(), DlgMainProc(), DlgStatProc(), do_barray_io(), do_sarray_io(), dummy_consume_data(), enable_allowed_controls(), finish_pass_gather(), free_pool(), get_dht(), get_interesting_appn(), get_sof(), handle_context_menu(), handle_copy_command(), handle_sequence_input(), idm_2_idc(), init_destination(), init_table_list(), InitInstance(), CMainWindow::InsertSelectionFromHBITMAP(), jcopy_block_row(), jcopy_sample_rows(), jinit_arith_decoder(), jinit_arith_encoder(), jinit_c_coef_controller(), jinit_c_main_controller(), jinit_c_master_control(), jinit_c_prep_controller(), jinit_color_converter(), jinit_color_deconverter(), jinit_d_coef_controller(), jinit_d_main_controller(), jinit_d_post_controller(), jinit_downsampler(), jinit_forward_dct(), jinit_huff_decoder(), jinit_huff_encoder(), jinit_input_controller(), jinit_inverse_dct(), jinit_marker_reader(), jinit_marker_writer(), jinit_master_decompress(), jinit_memory_mgr(), jinit_upsampler(), jpeg_alloc_huff_table(), jpeg_alloc_quant_table(), jpeg_copy_critical_parameters(), jpeg_CreateCompress(), jpeg_CreateDecompress(), jpeg_gen_optimal_table(), jpeg_make_c_derived_tbl(), jpeg_make_d_derived_tbl(), jpeg_mem_dest(), jpeg_mem_src(), jpeg_set_colorspace(), jpeg_set_defaults(), jpeg_stdio_dest(), jpeg_stdio_src(), keyword_type(), latch_quant_tables(), OFNHookProc(), CMainWindow::OnCommand(), CMainWindow::OnDropFiles(), CAttributesDialog::OnEdit1(), CAttributesDialog::OnEdit2(), CAttributesDialog::OnInitDialog(), PanelOnCreate(), post_key_press(), pre_process_data(), prepare_range_limit_table(), prepare_rpn_result_2(), process_vk_key(), query_from_path(), read_quant_tables(), realize_virt_arrays(), request_virt_barray(), request_virt_sarray(), rgb_ycc_start(), CMainWindow::saveImage(), self_destruct(), start_pass_huff(), SubclassButtonProc(), transencode_coef_controller(), update_menu(), and update_radio().

◆ WM_CLOSE_STATS

#define WM_CLOSE_STATS   (WM_APP+1)

Definition at line 16 of file calc.h.

Referenced by DlgMainProc(), and DlgStatProc().

◆ WM_HANDLE_CLIPBOARD

#define WM_HANDLE_CLIPBOARD   (WM_APP+2)

Definition at line 17 of file calc.h.

Referenced by DlgMainProc().

◆ WM_HANDLE_FROM

#define WM_HANDLE_FROM   (WM_APP+6)

Definition at line 21 of file calc.h.

Referenced by ConvExecute(), and DlgMainProc().

◆ WM_HANDLE_TO

#define WM_HANDLE_TO   (WM_APP+7)

Definition at line 22 of file calc.h.

Referenced by ConvExecute(), and DlgMainProc().

◆ WM_INSERT_STAT

#define WM_INSERT_STAT   (WM_APP+3)

Definition at line 18 of file calc.h.

Referenced by DlgStatProc(), and run_dat_sta().

◆ WM_LOAD_STAT

#define WM_LOAD_STAT   (WM_APP+4)

Definition at line 19 of file calc.h.

Referenced by DlgMainProc(), and DlgStatProc().

◆ WM_START_CONV

#define WM_START_CONV   (WM_APP+5)

Definition at line 20 of file calc.h.

Referenced by ConvExecute(), and DlgMainProc().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RPN_OPERATOR_PARENT 
RPN_OPERATOR_PERCENT 
RPN_OPERATOR_EQUAL 
RPN_OPERATOR_OR 
RPN_OPERATOR_XOR 
RPN_OPERATOR_AND 
RPN_OPERATOR_LSH 
RPN_OPERATOR_RSH 
RPN_OPERATOR_ADD 
RPN_OPERATOR_SUB 
RPN_OPERATOR_MULT 
RPN_OPERATOR_DIV 
RPN_OPERATOR_MOD 
RPN_OPERATOR_POW 
RPN_OPERATOR_SQR 
RPN_OPERATOR_NONE 

Definition at line 52 of file calc.h.

◆ anonymous enum

anonymous enum
Enumerator
CALC_LAYOUT_SCIENTIFIC 
CALC_LAYOUT_STANDARD 
CALC_LAYOUT_CONVERSION 

Definition at line 111 of file calc.h.

Function Documentation

◆ AboutDlgProc()

INT_PTR CALLBACK AboutDlgProc ( HWND  hWnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)

Definition at line 83 of file sndrec32.cpp.

Referenced by MenuCommand().

87 {
88  switch (msg)
89  {
90  case WM_COMMAND:
91  switch (LOWORD(wp))
92  {
93  case IDOK:
94  EndDialog(hWnd, 0);
95  return TRUE;
96  }
97  break;
98  case WM_CLOSE:
99  EndDialog(hWnd, 0);
100  return TRUE;
101  }
102  return FALSE;
103 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
UINT msg
Definition: msvc.h:92
#define WM_CLOSE
Definition: winuser.h:1603
#define WM_COMMAND
Definition: winuser.h:1716
#define LOWORD(l)
Definition: pedump.c:82

◆ apply_int_mask()

void apply_int_mask ( calc_number_t a)

Definition at line 3 of file fun_mpfr.c.

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

4 {
5  mpz_t a, mask;
6 
7  switch (calc.size) {
8  case IDC_RADIO_QWORD:
9  mpz_init_set_str(mask, "FFFFFFFFFFFFFFFF", 16);
10  break;
11  case IDC_RADIO_DWORD:
12  mpz_init_set_str(mask, "00000000FFFFFFFF", 16);
13  break;
14  case IDC_RADIO_WORD:
15  mpz_init_set_str(mask, "000000000000FFFF", 16);
16  break;
17  case IDC_RADIO_BYTE:
18  mpz_init_set_str(mask, "00000000000000FF", 16);
19  break;
20  default:
21  mpz_init_set_si(mask, -1);
22  }
23  mpz_init(a);
24  mpfr_get_z(a, r->mf, MPFR_DEFAULT_RND);
25  mpz_and(a, a, mask);
26  mpfr_set_z(r->mf, a, MPFR_DEFAULT_RND);
27  mpz_clear(a);
28  mpz_clear(mask);
29 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define IDC_RADIO_WORD
Definition: resource.h:79
GLuint const GLubyte mask[]
Definition: s_context.h:57
#define IDC_RADIO_QWORD
Definition: resource.h:77
#define a
Definition: ke_i.h:78
DWORD size
Definition: calc.h:139
#define IDC_RADIO_DWORD
Definition: resource.h:78
calc_t calc
Definition: winmain.c:226
#define IDC_RADIO_BYTE
Definition: resource.h:80

◆ ConvAdjust()

void ConvAdjust ( HWND  hWnd,
int  n_cat 
)

Definition at line 586 of file convert.c.

Referenced by ConvInit(), and DlgMainProc().

587 {
588  TCHAR txt[128];
589  TCHAR txt_cat[128];
590  HWND hFromWnd = GetDlgItem(hWnd, IDC_COMBO_FROM);
591  HWND hToWnd = GetDlgItem(hWnd, IDC_COMBO_TO);
592  const conv_t *item;
593  unsigned int n;
594 
595  SendDlgItemMessage(hWnd, IDC_COMBO_CATEGORY, CB_GETLBTEXT, n_cat, (LPARAM)txt_cat);
596  for (n=0; n<SIZEOF(conv_table); n++) {
597  item = conv_table[n].items;
599  if (!_tcscmp(txt_cat, txt))
600  break;
601  }
602 
603  SendMessage(hFromWnd, CB_RESETCONTENT, 0, 0);
604  SendMessage(hToWnd, CB_RESETCONTENT, 0, 0);
605  while (item->unit) {
606  LoadString(calc.hInstance, item->unit, txt, SIZEOF(txt));
607  SendMessage(hFromWnd, CB_ADDSTRING, 0, (LPARAM)txt);
608  SendMessage(hToWnd, CB_ADDSTRING, 0, (LPARAM)txt);
609  item++;
610  }
611  SendMessage(hFromWnd, CB_SETCURSEL, 0, 0);
612  SendMessage(hToWnd, CB_SETCURSEL, 0, 0);
613 }
DWORD unit
Definition: convert.c:27
Definition: convert.c:26
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define CB_GETLBTEXT
Definition: winuser.h:1913
#define SendDlgItemMessage
Definition: winuser.h:5708
const conv_t * items
Definition: convert.c:34
GLuint n
Definition: s_context.h:57
#define SIZEOF(_ar)
Definition: calc.h:48
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ADDSTRING
Definition: winuser.h:1897
HINSTANCE hInstance
Definition: calc.h:118
#define IDC_COMBO_CATEGORY
Definition: resource.h:100
#define CB_RESETCONTENT
Definition: winuser.h:1920
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_COMBO_FROM
Definition: resource.h:101
#define CB_SETCURSEL
Definition: winuser.h:1922
const DWORD category
Definition: convert.c:33
#define IDC_COMBO_TO
Definition: resource.h:102
static ATOM item
Definition: dde.c:856
static const conv_category_t conv_table[]
Definition: convert.c:517
#define SendMessage
Definition: winuser.h:5709
calc_t calc
Definition: winmain.c:226
#define LoadString
Definition: winuser.h:5685

◆ convert_real_integer()

void convert_real_integer ( unsigned int  base)

Definition at line 92 of file utl.c.

Referenced by update_radio().

93 {
94  switch (base) {
95  case IDC_RADIO_DEC:
96  calc.code.f = (double)calc.code.i;
97  break;
98  case IDC_RADIO_OCT:
99  case IDC_RADIO_BIN:
100  case IDC_RADIO_HEX:
101  if (calc.base == IDC_RADIO_DEC) {
102  calc.code.i = (__int64)calc.code.f;
104  }
105  break;
106  }
107 }
DWORD base
Definition: calc.h:138
calc_number_t code
Definition: calc.h:127
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
#define IDC_RADIO_BIN
Definition: resource.h:19
#define IDC_RADIO_HEX
Definition: resource.h:16
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
INT64 i
Definition: calc.h:78
#define IDC_RADIO_OCT
Definition: resource.h:18
calc_t calc
Definition: winmain.c:226
#define __int64
Definition: basetyps.h:16
void apply_int_mask(calc_number_t *a)
Definition: fun_mpfr.c:3

◆ convert_text2number_2()

void convert_text2number_2 ( calc_number_t a)

Definition at line 66 of file utl.c.

Referenced by convert_text2number().

67 {
68  TCHAR *ptr;
69 
70  switch (calc.base) {
71  case IDC_RADIO_HEX:
72  _stscanf(calc.buffer, TEXT("%I64X"), &(a->i));
73  break;
74  case IDC_RADIO_DEC:
75  _stscanf(calc.buffer, TEXT("%lf"), &(a->f));
76  break;
77  case IDC_RADIO_OCT:
78  _stscanf(calc.buffer, TEXT("%I64o"), &(a->i));
79  break;
80  case IDC_RADIO_BIN:
81  ptr = calc.buffer;
82  a->i = 0;
83  while (*ptr != TEXT('\0')) {
84  a->i <<= 1;
85  if (*ptr++ == TEXT('1'))
86  a->i |= 1;
87  }
88  break;
89  }
90 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
#define _stscanf
Definition: tchar.h:557
#define IDC_RADIO_BIN
Definition: resource.h:19
#define IDC_RADIO_HEX
Definition: resource.h:16
static PVOID ptr
Definition: dispmode.c:27
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
char TCHAR
Definition: xmlstorage.h:189
INT64 i
Definition: calc.h:78
#define TEXT(s)
Definition: k32.h:26
#define IDC_RADIO_OCT
Definition: resource.h:18
calc_t calc
Definition: winmain.c:226

◆ ConvExecute()

void ConvExecute ( HWND  hWnd)

Definition at line 533 of file convert.c.

Referenced by DlgMainProc().

534 {
536  const conv_t *items = NULL;
539  TCHAR txt_cb[128];
540  TCHAR txt[128];
541  const conv_t *item;
542 
543  /* do nothing if the indexes point to the same unit */
544  if (from == to)
545  return;
546 
547  /* Search correct category, since it can be sorted too */
549  for (c_cat=0; c_cat < SIZEOF(conv_table); c_cat++) {
550  LoadString(calc.hInstance, conv_table[c_cat].category, txt, SIZEOF(txt));
551  if (!_tcscmp(txt_cb, txt)) {
552  items = conv_table[c_cat].items;
553  break;
554  }
555  }
556 
557  /* The units can be sorted, so I must search the exact match */
558  item = items;
559  SendDlgItemMessage(hWnd, IDC_COMBO_FROM, CB_GETLBTEXT, from, (LPARAM)txt_cb);
560  while (item->unit) {
561  LoadString(calc.hInstance, item->unit, txt, SIZEOF(txt));
562  if (!_tcscmp(txt_cb, txt)) {
563  from = item-items;
564  break;
565  }
566  item++;
567  }
568  SendDlgItemMessage(hWnd, IDC_COMBO_TO, CB_GETLBTEXT, to, (LPARAM)txt_cb);
569  item = items;
570  while (item->unit) {
571  LoadString(calc.hInstance, item->unit, txt, SIZEOF(txt));
572  if (!_tcscmp(txt_cb, txt)) {
573  to = item-items;
574  break;
575  }
576  item++;
577  }
578 
579  calc.Convert[0].data = (char *)items[from].formula_from;
580  calc.Convert[1].data = (char *)items[to].formula_to;
584 }
DWORD unit
Definition: convert.c:27
sequence_t Convert[2]
Definition: calc.h:145
Definition: convert.c:26
UINT wm_msg
Definition: calc.h:102
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define CB_GETLBTEXT
Definition: winuser.h:1913
#define DWORD
Definition: msvc.h:34
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
#define WM_HANDLE_FROM
Definition: calc.h:21
#define SendDlgItemMessage
Definition: winuser.h:5708
const conv_t * items
Definition: convert.c:34
#define CB_GETCURSEL
Definition: winuser.h:1904
#define SIZEOF(_ar)
Definition: calc.h:48
LONG_PTR LPARAM
Definition: windef.h:208
smooth NULL
Definition: ftsmooth.c:416
HINSTANCE hInstance
Definition: calc.h:118
#define IDC_COMBO_CATEGORY
Definition: resource.h:100
#define PostMessage
Definition: winuser.h:5698
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_COMBO_FROM
Definition: resource.h:101
#define WM_START_CONV
Definition: calc.h:20
const DWORD category
Definition: convert.c:33
char * data
Definition: calc.h:100
#define IDC_COMBO_TO
Definition: resource.h:102
static ATOM item
Definition: dde.c:856
static const conv_category_t conv_table[]
Definition: convert.c:517
#define WM_HANDLE_TO
Definition: calc.h:22
CardRegion * from
Definition: spigame.cpp:19
static TCHAR * items[]
Definition: page1.c:45
calc_t calc
Definition: winmain.c:226
#define LoadString
Definition: winuser.h:5685

◆ ConvInit()

void ConvInit ( HWND  hWnd)

Definition at line 615 of file convert.c.

Referenced by DlgMainProc().

616 {
617  HWND hCatWnd = GetDlgItem(hWnd, IDC_COMBO_CATEGORY);
618  TCHAR txt[128];
619  unsigned int n;
620 
621  /* Fill category combo */
622  for (n=0; n<SIZEOF(conv_table); n++) {
624  SendMessage(hCatWnd, CB_ADDSTRING, 0, (LPARAM)txt);
625  }
626  SendMessage(hCatWnd, CB_SETCURSEL, 0, 0);
627  ConvAdjust(hWnd, 0);
628 }
void ConvAdjust(HWND hWnd, int n_cat)
Definition: convert.c:586
GLuint n
Definition: s_context.h:57
#define SIZEOF(_ar)
Definition: calc.h:48
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_ADDSTRING
Definition: winuser.h:1897
HINSTANCE hInstance
Definition: calc.h:118
#define IDC_COMBO_CATEGORY
Definition: resource.h:100
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CB_SETCURSEL
Definition: winuser.h:1922
const DWORD category
Definition: convert.c:33
static const conv_category_t conv_table[]
Definition: convert.c:517
#define SendMessage
Definition: winuser.h:5709
calc_t calc
Definition: winmain.c:226
#define LoadString
Definition: winuser.h:5685

◆ eval_parent_count()

int eval_parent_count ( void  )

Definition at line 432 of file rpn.c.

Referenced by update_parent_display().

433 {
434  stack_node_t *s = stack;
435  int n = 0;
436 
437  while (s != NULL) {
439  n++;
440  s = (stack_node_t *)(s->next);
441  }
442  return n;
443 }
static stack_node_t * stack
Definition: rpn.c:17
GLuint n
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
calc_node_t node
Definition: rpn.c:4
unsigned int operation
Definition: calc.h:85
void * next
Definition: rpn.c:5

◆ exec_change_infix()

void exec_change_infix ( void  )

Definition at line 397 of file rpn.c.

Referenced by DlgMainProc().

398 {
399  stack_node_t *op = stack;
400 
401  if (op == NULL)
402  return;
403  if (op->node.operation == RPN_OPERATOR_PARENT ||
406  return;
407  /* remove the head, it will be re-inserted with new operator */
408  pop();
409 }
static stack_node_t * pop(void)
Definition: rpn.c:70
static stack_node_t * stack
Definition: rpn.c:17
UINT op
Definition: effect.c:223
smooth NULL
Definition: ftsmooth.c:416
calc_node_t node
Definition: rpn.c:4
unsigned int operation
Definition: calc.h:85

◆ exec_closeparent()

void exec_closeparent ( calc_number_t )

Definition at line 411 of file rpn.c.

Referenced by run_rpar().

412 {
413  stack_node_t *op, ip;
414 
415  ip.node.number = *number;
416  ip.node.base = calc.base;
417  while (!is_stack_empty()) {
418  op = pop();
419 
421  break;
422 
423  run_operator(&ip.node, &op->node, &ip.node, op->node.operation);
424  if (calc.is_nan) {
425  flush_postfix();
426  return;
427  }
428  }
429  *number = ip.node.number;
430 }
DWORD base
Definition: calc.h:138
void flush_postfix()
Definition: rpn.c:445
static stack_node_t * pop(void)
Definition: rpn.c:70
BOOL is_nan
Definition: calc.h:132
static int is_stack_empty(void)
Definition: rpn.c:82
UINT op
Definition: effect.c:223
static size_t double number
Definition: printf.c:64
int ip[4]
Definition: rtl.c:1176
void run_operator(calc_node_t *result, calc_node_t *a, calc_node_t *b, unsigned int operation)
Definition: rpn.c:288
calc_number_t number
Definition: calc.h:84
calc_node_t node
Definition: rpn.c:4
DWORD base
Definition: calc.h:86
unsigned int operation
Definition: calc.h:85
calc_t calc
Definition: winmain.c:226

◆ exec_infix2postfix()

int exec_infix2postfix ( calc_number_t ,
unsigned  int 
)

Definition at line 365 of file rpn.c.

Referenced by DlgMainProc(), run_lpar(), run_pow(), and run_sqr().

366 {
367  stack_node_t tmp;
368 
369  if (is_stack_empty() && func == RPN_OPERATOR_EQUAL) {
370  /* if a number has been entered with exponential */
371  /* notation, I may update it with normal mode */
372  if (calc.sci_in)
373  return 1;
374  return 0;
375  }
376 
377  if (func == RPN_OPERATOR_PERCENT)
378  percent_mode = TRUE;
379 
380  tmp.node.number = *number;
381  tmp.node.base = calc.base;
382  tmp.node.operation = func;
383  tmp.next = NULL;
384 
385  push(&tmp);
386 
387  if (func == RPN_OPERATOR_NONE)
388  return 0;
389 
390  if (func != RPN_OPERATOR_PARENT) {
392  evalStack(number);
393  }
394  return 1;
395 }
GLenum func
Definition: glext.h:6028
DWORD base
Definition: calc.h:138
#define TRUE
Definition: types.h:120
static int is_stack_empty(void)
Definition: rpn.c:82
static size_t double number
Definition: printf.c:64
smooth NULL
Definition: ftsmooth.c:416
static void push(stack_node_t *op)
Definition: rpn.c:87
BOOL sci_in
Definition: calc.h:134
unsigned int last_operator
Definition: calc.h:146
calc_number_t number
Definition: calc.h:84
calc_node_t node
Definition: rpn.c:4
static void evalStack(calc_number_t *number)
Definition: rpn.c:331
static BOOL percent_mode
Definition: rpn.c:19
DWORD base
Definition: calc.h:86
unsigned int operation
Definition: calc.h:85
void * next
Definition: rpn.c:5
calc_t calc
Definition: winmain.c:226

◆ flush_postfix()

void flush_postfix ( void  )

Definition at line 445 of file rpn.c.

Referenced by evalStack(), exec_closeparent(), and run_canc().

446 {
447  while (!is_stack_empty())
448  pop();
449  /* clear prev and last typed operators */
451  calc.last_operator = 0;
452 }
static stack_node_t * pop(void)
Definition: rpn.c:70
static int is_stack_empty(void)
Definition: rpn.c:82
unsigned int prev_operator
Definition: calc.h:147
unsigned int last_operator
Definition: calc.h:146
calc_t calc
Definition: winmain.c:226

◆ 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

◆ prepare_rpn_result_2()

void prepare_rpn_result_2 ( calc_number_t rpn,
TCHAR buffer,
int  size,
int  base 
)

Definition at line 3 of file utl.c.

Referenced by prepare_rpn_result().

4 {
5  calc_number_t tmp;
6  int width;
7 
8  switch (base) {
9  case IDC_RADIO_HEX:
10  _stprintf(buffer, TEXT("%I64X"), rpn->i);
11  break;
12  case IDC_RADIO_DEC:
13 /*
14  * Modified from 17 to 16 for fixing this bug:
15  * 14+14+6.3+6.3= 40.5999999 instead of 40.6
16  * So, it's probably better to leave the least
17  * significant digit out of the display.
18  */
19 #define MAX_LD_WIDTH 16
20  /* calculate the width of integer number */
21  width = (rpn->f==0) ? 1 : (int)log10(fabs(rpn->f))+1;
22  if ((calc.sci_out != FALSE) || (width > MAX_LD_WIDTH) || (width < -MAX_LD_WIDTH))
23  _stprintf(buffer, TEXT("%#e"), rpn->f);
24  else {
25  TCHAR *ptr, *dst;
26 
27  ptr = buffer + _stprintf(buffer, TEXT("%#*.*f"), width, ((MAX_LD_WIDTH-width-1)>=0) ? MAX_LD_WIDTH-width-1 : 0, rpn->f);
28  /* format string ensures there is a '.': */
29  dst = _tcschr(buffer, TEXT('.'));
30  while (--ptr > dst)
31  if (*ptr != TEXT('0'))
32  break;
33 
34  /* put the string terminator for removing the final '0' (if any) */
35  ptr[1] = TEXT('\0');
36  /* check if the number finishes with '.' */
37  if (ptr == dst)
38  /* remove the dot (it will be re-added later) */
39  ptr[0] = TEXT('\0');
40  }
41 #undef MAX_LD_WIDTH
42  break;
43  case IDC_RADIO_OCT:
44  _stprintf(buffer, TEXT("%I64o"), rpn->i);
45  break;
46  case IDC_RADIO_BIN:
47  if (rpn->i == 0) {
48  buffer[0] = TEXT('0');
49  buffer[1] = TEXT('\0');
50  break;
51  }
52  tmp = *rpn;
53  buffer[0] = TEXT('\0');
54  while (tmp.u) {
55  memmove(buffer+1, buffer, (size-1)*sizeof(TCHAR));
56  if (tmp.u & 1)
57  calc.buffer[0] = TEXT('1');
58  else
59  calc.buffer[0] = TEXT('0');
60  tmp.u >>= 1;
61  }
62  break;
63  }
64 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
UINT64 u
Definition: calc.h:79
BOOL sci_out
Definition: calc.h:133
#define IDC_RADIO_DEC
Definition: resource.h:17
double f
Definition: calc.h:77
GLuint buffer
Definition: glext.h:5915
#define IDC_RADIO_BIN
Definition: resource.h:19
#define IDC_RADIO_HEX
Definition: resource.h:16
static PVOID ptr
Definition: dispmode.c:27
TCHAR buffer[MAX_CALC_SIZE]
Definition: calc.h:124
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
GLsizeiptr size
Definition: glext.h:5919
INT64 i
Definition: calc.h:78
_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)
#define _stprintf
Definition: utility.h:124
#define TEXT(s)
Definition: k32.h:26
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
#define MAX_LD_WIDTH
#define IDC_RADIO_OCT
Definition: resource.h:18
calc_t calc
Definition: winmain.c:226

◆ rpn_2pi()

void rpn_2pi ( calc_number_t c)

Definition at line 274 of file fun_mpfr.c.

275 {
276  mpfr_const_pi(c->mf, MPFR_DEFAULT_RND);
277  mpfr_mul_ui(c->mf, c->mf, 2, MPFR_DEFAULT_RND);
278 }

◆ rpn_acos()

void rpn_acos ( calc_number_t c)

Definition at line 181 of file fun_mpfr.c.

182 {
183  mpfr_acos(c->mf, c->mf, MPFR_DEFAULT_RND);
185 }
void validate_rad2angle(calc_number_t *r)
Definition: fun_mpfr.c:31

◆ rpn_acosh()

void rpn_acosh ( calc_number_t c)

Definition at line 213 of file fun_mpfr.c.

214 {
215  mpfr_acosh(c->mf, c->mf, MPFR_DEFAULT_RND);
216  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
217 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_alloc()

void rpn_alloc ( calc_number_t c)

Definition at line 482 of file fun_mpfr.c.

Referenced by exec_closeparent(), and run_dat_sta().

483 {
484  mpfr_init(c->mf);
485 }

◆ rpn_asin()

void rpn_asin ( calc_number_t c)

Definition at line 176 of file fun_mpfr.c.

177 {
178  mpfr_asin(c->mf, c->mf, MPFR_DEFAULT_RND);
180 }
void validate_rad2angle(calc_number_t *r)
Definition: fun_mpfr.c:31

◆ rpn_asinh()

void rpn_asinh ( calc_number_t c)

Definition at line 208 of file fun_mpfr.c.

209 {
210  mpfr_asinh(c->mf, c->mf, MPFR_DEFAULT_RND);
211  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
212 }
#define TRUE
Definition: types.h:120
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 186 of file fun_mpfr.c.

187 {
188  mpfr_atan(c->mf, c->mf, MPFR_DEFAULT_RND);
190 }
void validate_rad2angle(calc_number_t *r)
Definition: fun_mpfr.c:31

◆ rpn_atanh()

void rpn_atanh ( calc_number_t c)

Definition at line 218 of file fun_mpfr.c.

219 {
220  mpfr_atanh(c->mf, c->mf, MPFR_DEFAULT_RND);
221  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
222 }
#define TRUE
Definition: types.h:120
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 344 of file fun_mpfr.c.

345 {
346  int n;
347 
348  stat_sum(c->mf);
350 
351  if (n)
352  mpfr_div_ui(c->mf, c->mf, n, MPFR_DEFAULT_RND);
353 
354  if (calc.base != IDC_RADIO_DEC)
355  mpfr_trunc(c->mf, c->mf);
356 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
#define SendDlgItemMessage
Definition: winuser.h:5708
GLuint n
Definition: s_context.h:57
#define LB_GETCOUNT
Definition: winuser.h:1999
static void stat_sum(mpfr_t sum)
Definition: fun_mpfr.c:333
HWND hStatWnd
Definition: calc.h:142
#define IDC_LIST_STAT
Definition: resource.h:90
calc_t calc
Definition: winmain.c:226

◆ rpn_cbrt()

void rpn_cbrt ( calc_number_t c)

Definition at line 303 of file fun_mpfr.c.

304 {
305  mpfr_cbrt(c->mf, c->mf, MPFR_DEFAULT_RND);
306  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
307 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_copy()

void rpn_copy ( calc_number_t dst,
calc_number_t src 
)

Definition at line 472 of file fun_mpfr.c.

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

473 {
474  mpfr_set(dst->mf, src->mf, MPFR_DEFAULT_RND);
475 }

◆ rpn_cos()

void rpn_cos ( calc_number_t c)

Definition at line 130 of file fun_mpfr.c.

131 {
132  mpfr_t mp_pi, mp_pi_2, mp_3_pi_2, mp_2_pi;
133 
135  build_rad_const(&mp_pi, &mp_pi_2, &mp_3_pi_2, &mp_2_pi);
136 
137  if (!mpfr_cmp(c->mf, mp_pi_2) || !mpfr_cmp(c->mf, mp_3_pi_2))
138  rpn_zero(c);
139  else
140  if (!mpfr_cmp(c->mf, mp_pi))
141  mpfr_set_si(c->mf, -1, MPFR_DEFAULT_RND);
142  else
143  if (!mpfr_cmp(c->mf, mp_2_pi))
144  mpfr_set_si(c->mf, 1, MPFR_DEFAULT_RND);
145  else {
146  mpfr_cos(c->mf, c->mf, MPFR_DEFAULT_RND);
147  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
148  }
149  mpfr_clear(mp_pi);
150  mpfr_clear(mp_pi_2);
151  mpfr_clear(mp_3_pi_2);
152  mpfr_clear(mp_2_pi);
153 }
#define TRUE
Definition: types.h:120
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
BOOL is_nan
Definition: calc.h:132
void validate_angle2rad(calc_number_t *r)
Definition: fun_mpfr.c:58
static void build_rad_const(mpfr_t *mp_pi, mpfr_t *mp_pi_2, mpfr_t *mp_3_pi_2, mpfr_t *mp_2_pi)
Definition: fun_mpfr.c:89
calc_t calc
Definition: winmain.c:226

◆ rpn_cosh()

void rpn_cosh ( calc_number_t c)

Definition at line 197 of file fun_mpfr.c.

198 {
199  mpfr_cosh(c->mf, c->mf, MPFR_DEFAULT_RND);
200  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
201 }
#define TRUE
Definition: types.h:120
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 440 of file fun_mpfr.c.

441 {
442  mpfr_t d, m, s;
443 
444  mpfr_init(d);
445  mpfr_init(m);
446  mpfr_init(s);
447 
448  mpfr_trunc(d, c->mf);
449  mpfr_frac(m, c->mf, MPFR_DEFAULT_RND);
450  mpfr_mul_ui(m, m, 60, MPFR_DEFAULT_RND);
451 
452  mpfr_frac(s, m, MPFR_DEFAULT_RND);
453  mpfr_trunc(m, m);
454  mpfr_mul_ui(s, s, 60, MPFR_DEFAULT_RND);
455  mpfr_ceil(s, s);
456 
457  mpfr_div_ui(m, m, 100, MPFR_DEFAULT_RND);
458  mpfr_div_ui(s, s, 10000, MPFR_DEFAULT_RND);
459  mpfr_add(c->mf, d, m, MPFR_DEFAULT_RND);
460  mpfr_add(c->mf, c->mf, s, MPFR_DEFAULT_RND);
461 
462  mpfr_clear(d);
463  mpfr_clear(m);
464  mpfr_clear(s);
465 }
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039
CONST GLfloat m[16]
Definition: m_xform.h:144

◆ rpn_dms2dec()

void rpn_dms2dec ( calc_number_t c)

Definition at line 413 of file fun_mpfr.c.

414 {
415  mpfr_t d, m, s;
416 
417  mpfr_init(d);
418  mpfr_init(m);
419  mpfr_init(s);
420 
421  mpfr_trunc(d, c->mf);
422  mpfr_frac(m, c->mf, MPFR_DEFAULT_RND);
423  mpfr_mul_ui(m, m, 100, MPFR_DEFAULT_RND);
424 
425  mpfr_frac(s, m, MPFR_DEFAULT_RND);
426  mpfr_trunc(m, m);
427  mpfr_mul_ui(s, s, 100, MPFR_DEFAULT_RND);
428  mpfr_ceil(s, s);
429 
430  mpfr_div_ui(m, m, 60, MPFR_DEFAULT_RND);
431  mpfr_div_ui(s, s, 3600, MPFR_DEFAULT_RND);
432  mpfr_add(c->mf, d, m, MPFR_DEFAULT_RND);
433  mpfr_add(c->mf, c->mf, s, MPFR_DEFAULT_RND);
434 
435  mpfr_clear(d);
436  mpfr_clear(m);
437  mpfr_clear(s);
438 }
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039
CONST GLfloat m[16]
Definition: m_xform.h:144

◆ rpn_exp()

void rpn_exp ( calc_number_t c)

Definition at line 309 of file fun_mpfr.c.

310 {
311  mpfr_exp(c->mf, c->mf, MPFR_DEFAULT_RND);
312  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
313 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_exp10()

void rpn_exp10 ( calc_number_t c)

Definition at line 315 of file fun_mpfr.c.

316 {
317  mpfr_exp10(c->mf, c->mf, MPFR_DEFAULT_RND);
318  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
319 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_exp2()

void rpn_exp2 ( calc_number_t c)

Definition at line 285 of file fun_mpfr.c.

286 {
287  mpfr_sqr(c->mf, c->mf, MPFR_DEFAULT_RND);
288  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
289 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_exp3()

void rpn_exp3 ( calc_number_t c)

Definition at line 291 of file fun_mpfr.c.

292 {
293  mpfr_pow_ui(c->mf, c->mf, 3, MPFR_DEFAULT_RND);
294  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
295 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_fact()

void rpn_fact ( calc_number_t c)

Definition at line 242 of file fun_mpfr.c.

243 {
244  if (mpfr_sgn(c->mf) < 0) {
245  calc.is_nan = TRUE;
246  return;
247  }
248 
249  mpfr_trunc(c->mf, c->mf);
250  if (mpfr_fits_ulong_p(c->mf, MPFR_DEFAULT_RND) == 0)
251  calc.is_nan = TRUE;
252  else {
253  mpfr_fac_ui(c->mf, mpfr_get_ui(c->mf, MPFR_DEFAULT_RND), MPFR_DEFAULT_RND);
254  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
255  }
256 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_frac()

void rpn_frac ( calc_number_t c)

Definition at line 229 of file fun_mpfr.c.

230 {
231  mpfr_frac(c->mf, c->mf, MPFR_DEFAULT_RND);
232 }

◆ rpn_free()

void rpn_free ( calc_number_t c)

Definition at line 487 of file fun_mpfr.c.

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

488 {
489  mpfr_clear(c->mf);
490 }

◆ rpn_int()

void rpn_int ( calc_number_t c)

Definition at line 224 of file fun_mpfr.c.

Referenced by rpn_fact().

225 {
226  mpfr_trunc(c->mf, c->mf);
227 }

◆ rpn_is_zero()

int rpn_is_zero ( calc_number_t c)

Definition at line 477 of file fun_mpfr.c.

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

478 {
479  return (mpfr_sgn(c->mf) == 0);
480 }

◆ rpn_ln()

void rpn_ln ( calc_number_t c)

Definition at line 321 of file fun_mpfr.c.

322 {
323  mpfr_log(c->mf, c->mf, MPFR_DEFAULT_RND);
324  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
325 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_log()

void rpn_log ( calc_number_t c)

Definition at line 327 of file fun_mpfr.c.

328 {
329  mpfr_log10(c->mf, c->mf, MPFR_DEFAULT_RND);
330  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
331 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_not()

void rpn_not ( calc_number_t c)

Definition at line 258 of file fun_mpfr.c.

259 {
260  mpz_t a;
261 
262  mpz_init(a);
263  mpfr_get_z(a, c->mf, MPFR_DEFAULT_RND);
264  mpz_com(a, a);
265  mpfr_set_z(c->mf, a, MPFR_DEFAULT_RND);
266  mpz_clear(a);
267 }
#define a
Definition: ke_i.h:78

◆ rpn_pi()

void rpn_pi ( calc_number_t c)

Definition at line 269 of file fun_mpfr.c.

270 {
271  mpfr_const_pi(c->mf, MPFR_DEFAULT_RND);
272 }

◆ rpn_reci()

void rpn_reci ( calc_number_t c)

Definition at line 234 of file fun_mpfr.c.

235 {
236  if (mpfr_sgn(c->mf) == 0)
237  calc.is_nan = TRUE;
238  else
239  mpfr_ui_div(c->mf, 1, c->mf, MPFR_DEFAULT_RND);
240 }
#define TRUE
Definition: types.h:120
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 403 of file fun_mpfr.c.

404 {
405  rpn_s_ex(c, 0);
406 }
static void rpn_s_ex(calc_number_t *c, int pop_type)
Definition: fun_mpfr.c:366

◆ rpn_s_m1()

void rpn_s_m1 ( calc_number_t c)

Definition at line 408 of file fun_mpfr.c.

409 {
410  rpn_s_ex(c, 1);
411 }
static void rpn_s_ex(calc_number_t *c, int pop_type)
Definition: fun_mpfr.c:366

◆ rpn_sign()

void rpn_sign ( calc_number_t c)

Definition at line 280 of file fun_mpfr.c.

Referenced by DlgMainProc().

281 {
282  mpfr_mul_si(c->mf, c->mf, -1, MPFR_DEFAULT_RND);
283 }

◆ rpn_sin()

void rpn_sin ( calc_number_t c)

Definition at line 106 of file fun_mpfr.c.

107 {
108  mpfr_t mp_pi, mp_pi_2, mp_3_pi_2, mp_2_pi;
109 
111  build_rad_const(&mp_pi, &mp_pi_2, &mp_3_pi_2, &mp_2_pi);
112 
113  if (rpn_is_zero(c) || !mpfr_cmp(c->mf, mp_pi) || !mpfr_cmp(c->mf, mp_2_pi))
114  rpn_zero(c);
115  else
116  if (!mpfr_cmp(c->mf, mp_3_pi_2))
117  mpfr_set_si(c->mf, -1, MPFR_DEFAULT_RND);
118  else
119  if (!mpfr_cmp(c->mf, mp_pi_2))
120  mpfr_set_si(c->mf, 1, MPFR_DEFAULT_RND);
121  else {
122  mpfr_sin(c->mf, c->mf, MPFR_DEFAULT_RND);
123  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
124  }
125  mpfr_clear(mp_pi);
126  mpfr_clear(mp_pi_2);
127  mpfr_clear(mp_3_pi_2);
128  mpfr_clear(mp_2_pi);
129 }
#define TRUE
Definition: types.h:120
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
int rpn_is_zero(calc_number_t *c)
Definition: fun_mpfr.c:477
BOOL is_nan
Definition: calc.h:132
void validate_angle2rad(calc_number_t *r)
Definition: fun_mpfr.c:58
static void build_rad_const(mpfr_t *mp_pi, mpfr_t *mp_pi_2, mpfr_t *mp_3_pi_2, mpfr_t *mp_2_pi)
Definition: fun_mpfr.c:89
calc_t calc
Definition: winmain.c:226

◆ rpn_sinh()

void rpn_sinh ( calc_number_t c)

Definition at line 192 of file fun_mpfr.c.

193 {
194  mpfr_sinh(c->mf, c->mf, MPFR_DEFAULT_RND);
195  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
196 }
#define TRUE
Definition: types.h:120
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 297 of file fun_mpfr.c.

298 {
299  mpfr_sqrt(c->mf, c->mf, MPFR_DEFAULT_RND);
300  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
301 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_sum()

void rpn_sum ( calc_number_t c)

Definition at line 358 of file fun_mpfr.c.

359 {
360  stat_sum(c->mf);
361 
362  if (calc.base != IDC_RADIO_DEC)
363  mpfr_trunc(c->mf, c->mf);
364 }
DWORD base
Definition: calc.h:138
#define IDC_RADIO_DEC
Definition: resource.h:17
static void stat_sum(mpfr_t sum)
Definition: fun_mpfr.c:333
calc_t calc
Definition: winmain.c:226

◆ rpn_tan()

void rpn_tan ( calc_number_t c)

Definition at line 154 of file fun_mpfr.c.

155 {
156  mpfr_t mp_pi, mp_pi_2, mp_3_pi_2, mp_2_pi;
157 
159  build_rad_const(&mp_pi, &mp_pi_2, &mp_3_pi_2, &mp_2_pi);
160 
161  if (!mpfr_cmp(c->mf, mp_pi_2) || !mpfr_cmp(c->mf, mp_3_pi_2))
162  calc.is_nan = TRUE;
163  else
164  if (!mpfr_cmp(c->mf, mp_pi) || !mpfr_cmp(c->mf, mp_2_pi))
165  rpn_zero(c);
166  else {
167  mpfr_tan(c->mf, c->mf, MPFR_DEFAULT_RND);
168  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
169  }
170  mpfr_clear(mp_pi);
171  mpfr_clear(mp_pi_2);
172  mpfr_clear(mp_3_pi_2);
173  mpfr_clear(mp_2_pi);
174 }
#define TRUE
Definition: types.h:120
void rpn_zero(calc_number_t *c)
Definition: fun_mpfr.c:467
BOOL is_nan
Definition: calc.h:132
void validate_angle2rad(calc_number_t *r)
Definition: fun_mpfr.c:58
static void build_rad_const(mpfr_t *mp_pi, mpfr_t *mp_pi_2, mpfr_t *mp_3_pi_2, mpfr_t *mp_2_pi)
Definition: fun_mpfr.c:89
calc_t calc
Definition: winmain.c:226

◆ rpn_tanh()

void rpn_tanh ( calc_number_t c)

Definition at line 202 of file fun_mpfr.c.

203 {
204  mpfr_tanh(c->mf, c->mf, MPFR_DEFAULT_RND);
205  if (!mpfr_number_p(c->mf)) calc.is_nan = TRUE;
206 }
#define TRUE
Definition: types.h:120
BOOL is_nan
Definition: calc.h:132
calc_t calc
Definition: winmain.c:226

◆ rpn_validate_result()

BOOL rpn_validate_result ( calc_number_t c)

◆ rpn_zero()

void rpn_zero ( calc_number_t c)

Definition at line 467 of file fun_mpfr.c.

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

468 {
469  mpfr_set_ui(c->mf, 0, MPFR_DEFAULT_RND);
470 }

◆ run_operator()

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

Definition at line 288 of file rpn.c.

Referenced by evalStack(), exec_closeparent(), run_mm(), and run_mp().

292 {
293  calc_number_t da, db, dc;
294  DWORD base = calc.base;
295 
296  da = a->number;
297  db = b->number;
298  if (a->base == IDC_RADIO_DEC && b->base != IDC_RADIO_DEC) {
299  db.f = logic_int2dbl(&b->number);
300  base = IDC_RADIO_DEC;
301  } else
302  if (a->base != IDC_RADIO_DEC && b->base == IDC_RADIO_DEC) {
303  da.f = logic_int2dbl(&a->number);
304  base = IDC_RADIO_DEC;
305  }
306 
307  if (base == IDC_RADIO_DEC) {
308  if (percent_mode) {
310  operator_list[operation].op_p(&dc, &da, &db);
311  } else
312  operator_list[operation].op_f(&dc, &da, &db);
313  if (_finite(dc.f) == 0)
314  calc.is_nan = TRUE;
315  } else {
316  operator_list[operation].op_i(&dc, &da, &db);
317  /* apply final limiter to result */
318  apply_int_mask(&dc);
319  }
320 
321  if (a->base == IDC_RADIO_DEC && b->base != IDC_RADIO_DEC) {
322  result->number.i = logic_dbl2int(&dc);
323  apply_int_mask(&result->number);
324  } else
325  if (a->base != IDC_RADIO_DEC && b->base == IDC_RADIO_DEC)
326  result->number.f = dc.f;
327  else
328  result->number = dc;
329 }
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
HDC dc
Definition: cylfrac.c:34
double logic_int2dbl(calc_number_t *a)
Definition: function.c:253
BOOL is_nan
Definition: calc.h:132
__int64 logic_dbl2int(calc_number_t *a)
Definition: function.c:240
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
INT64 i
Definition: calc.h:78
unsigned long DWORD
Definition: ntddk_ex.h:95
calc_number_t number
Definition: calc.h:84
operator_call op_f
Definition: rpn.c:12
static BOOL percent_mode
Definition: rpn.c:19
DWORD base
Definition: calc.h:86
static const calc_operator_t operator_list[]
Definition: rpn.c:52
operator_call op_i
Definition: rpn.c:13
operator_call op_p
Definition: rpn.c:14
calc_t calc
Definition: winmain.c:226
void apply_int_mask(calc_number_t *a)
Definition: fun_mpfr.c:3

◆ start_rpn_engine()

void start_rpn_engine ( void  )

Definition at line 454 of file rpn.c.

Referenced by _tWinMain().

455 {
456  stack = NULL;
457 }
smooth NULL
Definition: ftsmooth.c:416
Definition: _stack.h:47

◆ stop_rpn_engine()

void stop_rpn_engine ( void  )

Definition at line 459 of file rpn.c.

Referenced by _tWinMain().

460 {
461 }

◆ validate_angle2rad()

double validate_angle2rad ( calc_number_t c)

Definition at line 58 of file fun_mpfr.c.

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

59 {
60  mpfr_t mult, divs;
61 
62  if (!mpfr_number_p(r->mf)) {
63  calc.is_nan = TRUE;
64  return;
65  }
66  mpfr_init(mult);
67  mpfr_init(divs);
68  switch (calc.degr) {
69  case IDC_RADIO_DEG:
70  mpfr_const_pi(mult, MPFR_DEFAULT_RND);
71  mpfr_set_ui(divs, 180, MPFR_DEFAULT_RND);
72  break;
73  case IDC_RADIO_RAD:
74  mpfr_set_ui(mult, 1, MPFR_DEFAULT_RND);
75  mpfr_set_ui(divs, 1, MPFR_DEFAULT_RND);
76  break;
77  case IDC_RADIO_GRAD:
78  mpfr_const_pi(mult, MPFR_DEFAULT_RND);
79  mpfr_set_ui(divs, 200, MPFR_DEFAULT_RND);
80  break;
81  }
82  mpfr_mul(r->mf, r->mf, mult, MPFR_DEFAULT_RND);
83  mpfr_div(r->mf, r->mf, divs, MPFR_DEFAULT_RND);
84 
85  mpfr_clear(mult);
86  mpfr_clear(divs);
87 }
#define IDC_RADIO_DEG
Definition: resource.h:81
#define TRUE
Definition: types.h:120
#define IDC_RADIO_GRAD
Definition: resource.h:83
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
DWORD degr
Definition: calc.h:140
BOOL is_nan
Definition: calc.h:132
#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

Variable Documentation

◆ calc