File: calculator.h

package info (click to toggle)
wcalc 2.3.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,444 kB
  • ctags: 926
  • sloc: ansic: 8,993; objc: 1,946; lex: 798; sh: 766; yacc: 623; makefile: 79
file content (164 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 *  calculator.h
 *  Wcalc
 *
 *  Created by Kyle Wheeler on Thu Feb 07 2002.
 *  Copyright (c) 2001 Kyle Wheeler. All rights reserved.
 *
 */

#ifndef WCALC_CALCULATOR_H
#define WCALC_CALCULATOR_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "definitions.h"

#include "number.h"

#ifdef EBUG
#include <stdio.h>
#define Dprintf(fmt, ...) \
	fprintf(stderr, "[%s:%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \
	fflush(stderr);
#else
#define Dprintf(...) ;
#endif

enum functions
{ wnot,
    wbnot,
    wsin,
    wcos,
    wtan,
    wcot,
    wsec,
    wcsc,
    wasin,
    wacos,
    watan,
    wacot,
    wasec,
    wacsc,
    wsinh,
    wcosh,
    wtanh,
    wcoth,
    wsech,
    wcsch,
    wasinh,
    wacosh,
    watanh,
    wacoth,
    wasech,
    wacsch,
    wlog,
    wlogtwo,
    wln,
    wround,
    wneg,
    wabs,
    wsqrt,
    wfloor,
    wceil,
    wrand,
    wirand,
    wexp,
    wfact,
    wcomp,
    weint,
    wgamma,
    wlngamma,
    wzeta,
    wsinc,
    wcbrt
};
enum operations
{ wplus,
    wminus,
    wmult,
    wdiv,
    wmod,
    wpow,
    wor,
    wbor,
    wbxor,
    wand,
    wband,
    wequal,
    wnequal,
    wgt,
    wlt,
    wrshft,
    wlshft,
    wgeq,
    wleq,
    wnone
};
enum commands
{ redisplay, nothing };

enum engineering_modes
{ always, never, automatic };

void parseme(const char *);
void report_error(const char * fmt, ...);
void display_and_clear_errstring(void);
void set_prettyanswer(const Number num);
char *print_this_result(const Number result);
void uber_function(Number output, const enum functions func, Number input);
void simple_exp(Number output, const Number first, const enum operations op,
				const Number second);
int seed_random(void);
char *output_string(const unsigned int);

struct _conf
{
    int precision;
    enum engineering_modes engineering:2;
    unsigned int picky_variables:1;
    unsigned int use_radians:1;
    unsigned int output_format:4;
    unsigned int print_prefixes:1;
    unsigned int rounding_indication:4;
    unsigned int remember_errors:1;
    char thou_delimiter;
    char dec_delimiter;
    unsigned int precision_guard:1;
    unsigned int history_limit:1;
    unsigned long history_limit_len;
    unsigned int print_equal:1;
    unsigned int print_ints:1;
    unsigned int simple_calc:1;
    unsigned int verbose:1;
    unsigned int print_commas:1;
    unsigned int live_precision:1;
    unsigned int c_style_mod:1;
};

/* configuration */
extern struct _conf conf;

/* results */
extern Number last_answer;
extern char *pretty_answer;

/* communication with parser */
extern char compute;
extern unsigned int sig_figs;

/* communication with the frontend */
extern char standard_output;
extern char not_all_displayed;

#define DECIMAL_FORMAT 0
#define OCTAL_FORMAT 1
#define HEXADECIMAL_FORMAT 2
#define BINARY_FORMAT 3

#define NO_ROUNDING_INDICATION 0
#define SIMPLE_ROUNDING_INDICATION 1
#define SIG_FIG_ROUNDING_INDICATION 2

#endif