amath  1.8.5
Simple command line calculator
main.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * Project homepage:
26  * https://amath.innolan.net
27  *
28  */
29 
30 /*!
31  \mainpage Simple command line calculator
32  \section intro_sec Introduction
33 
34  A mathematical calculator capable of evaluating arithmetic expressions.
35  Main features include:
36  - Case sensitive command line interface
37  - Native IEEE 754 with 15 significant digits
38  - Calculations with real and complex numbers
39  - Variables and user defined functions
40  - Logarithmic and exponential functions
41  - Trigonometric and hyperbolic functions
42  - Mathematical constants and rounding functions
43  - Disk functions to load, save and view content
44  - Comprehensive and easy to use built-in help
45  - Freely distributable sources (BSD \ref license_page)
46 
47  \subsection install Installation
48  Install by copying the desired amath binary to C: or any other appropriate location.
49 
50  \subsection usage Usage
51  amath supply 50 \ref command_page combined with 7 arithmetic operators:
52  \verbatim
53  + Mathematical addition
54  - Mathematical subtraction
55  * Mathematical multiplication
56  / Mathematical division
57  ^ Mathematical exponentiation
58  = Assignment of variable values
59  | Absolute value of number
60  \endverbatim
61 
62  Do a calculation in shell (CLI mode):
63  > amath 1.2+1.4
64 
65  Get an interactive promt in shell:
66  > amath shell
67 
68  Show version string:
69  > amath version
70 
71  Open amath in its own window:
72  > amath
73 
74  \subsection license License
75  amath is open source. The main repository is located at gitlab:<BR>
76  https://gitlab.com/rnger/amath <BR>
77  <BR>
78  Github has a mirror:<BR>
79  https://github.com/rainlance/amath
80 
81  \subsection download Download
82  FreeBSD: <a href="https://www.freshports.org/math/amath/">freshports.org</a><BR>
83  Haiku OS: <a href="https://depot.haiku-os.org/#!/pkg/amath/haikuports/1/8/3/-/1/x86_gcc2">depot.haiku-os.org</a><BR>
84  Mac OS X and Linux: <a href="https://pkgsrc.joyent.com">pkgsrc.joyent.com</a><<BR>
85  NetBSD: <a href="http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/math/amath/README.html">netbsd.org</a> and
86  <a href="http://pkgsrc.se/math/amath">pkgsrc.se</a><BR>
87  Windows: <a href="http://amath.innolan.net/amath-1.8.3-win.zip">amath.innolan.net</a><BR>
88  Other packages: <a href="http://ftp.innolan.net/pub/amath/">ftp.innolan.net</a>
89  \subsection history History
90  A full \ref release_page is available for amath.
91 
92  \page command_page Statements and functions
93  \section command_sec Statements and functions
94 
95  \subsection command_stat Statements
96  \verbatim
97 
98  about Show about text
99  clear Clear console window
100  def Define function
101  delete Delete variable or function
102  digits Set number of significant digits
103  eval Evaluate arithmetic expression
104  execute Execute statements in a file
105  functions Show list of user defined functions
106  input Change numeral input system
107  help Show basic help text
108  output Change numeral output system
109  list Show content of a directory
110  show Show content of a file
111  load Load variable and functions from file
112  save Save variable and functions to file
113  variables Show list of variables
114  version Show version string
115  license Show copyright and license texts
116  memory Show internal memory usage
117  exit Exit program
118  \endverbatim
119  \subsection command_func Miscellaneous functions
120  \verbatim
121  abs Absolute value of number
122  sgn Mathematical signum function
123  round Round to nearest integer number
124  trunc Discard fraction part of number
125  floor Mathematical floor function
126  ceil Mathematical ceiling function
127  sqrt Square root function (exp 1/2)
128  cbrt Cube root function (exp 1/3)
129  lb Binary logarithm function (base 2)
130  ln Natural logarithm function (base e)
131  lg Common logarithm function (base 10)
132  \endverbatim
133  \subsection command_trig Trigonometric functions
134  \verbatim
135  sin Trigonometric sine function
136  cos Trigonometric cosine function
137  tan Trigonometric tangent function
138  cot Trigonometric cotangent function
139  sec Trigonometric secant function
140  csc Trigonometric cosecant function
141  crd Trigonometric chord function
142  exsec Trigonometric exsecant function
143  excsc Trigonometric excosecant function
144  arcsin Inverse trigonometric sine function
145  arccos Inverse trigonometric cosine function
146  arctan Inverse trigonometric tangent function
147  arccot Inverse trigonometric cotangent function
148  arcsec Inverse trigonometric secant function
149  arccsc Inverse trigonometric cosecant function
150  arccrd Inverse trigonometric chord function
151  arcexsec Inverse trigonometric exsecant function
152  arcexcsc Inverse trigonometric excosecant function
153  \endverbatim
154  \subsection command_hype Hyperbolic functions
155  \verbatim
156  sinh Hyperbolic sine function
157  cosh Hyperbolic cosine function
158  tanh Hyperbolic tangent function
159  coth Hyperbolic cotangent function
160  sech Hyperbolic secant function
161  csch Hyperbolic cosecant function
162  arcsinh Inverse hyperbolic sine function
163  arccosh Inverse hyperbolic cosine function
164  arctanh Inverse hyperbolic tangent function
165  arccoth Inverse hyperbolic cotangent function
166  arcsech Inverse hyperbolic secant function
167  arccsch Inverse hyperbolic cosecant function
168  \endverbatim
169  \subsection command_earl Early trigonometric functions
170  \verbatim
171  ver Versed sine function
172  vcs Versed cosine function
173  cvs Coversed sine function
174  cvc Coversed cosine function
175  hv Haversed sine function
176  hvc Haversed cosine function
177  hcv Hacoversed sine function
178  hcc Hacoversed cosine function
179  arcver Inverse versed sine function
180  arcvcs Inverse versed cosine function
181  arccvs Inverse coversed sine function
182  arccvc Inverse coversed cosine function
183  archv Inverse haversed sine function
184  archvc Inverse haversed cosine function
185  archcv Inverse hacoversed sine function
186  archcc Inverse hacoversed cosine function
187  \endverbatim
188  \subsection command_vars Variables and constant
189  \verbatim
190  pi Trigonometric constant
191  e Euler's number
192  i Imaginary unit
193  ins Result of last calculation
194  \endverbatim
195  \subsection command_exfunc Example script
196  \verbatim
197  round(1.5461);round(-1.5461);
198  ceil(43.5461);ceil(-43.5461);
199  floor(39.9531);floor(-39.9531);
200  trunc(23.827);trunc(-23.827);
201  sqrt(100);sqrt(52.23);
202  \endverbatim
203  \subsection command_exuserfunc Example script with functions
204  \verbatim
205  f(x)=x*2+1;
206  g(y)=y^2+y*1.5+2;
207  a=2;b=3;c=a+b;
208  vars;funcs;
209  f(2.2);c+1.1;
210  \endverbatim
211  \subsection command_excomplex Example script with complex numbers
212  \verbatim
213  cos(1+2i);
214  sin(1+2i);
215  tan(1+2i);
216  coth(1+2i);
217  sech(1+2i);
218  csch(1+2i);
219  \endverbatim
220 
221  \page license_page License
222  \section license_sec License
223  amath is using a permissive free software licenses.
224 
225  \subsection license_bsd BSD License
226  <BLOCKQUOTE><PRE>
227  Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
228  Copyright (c) 2007 The NetBSD Foundation, Inc.
229  Copyright (c) 1990, 1993 The Regents of the University of California.
230  All rights reserved.
231 
232  Redistribution and use in source and binary forms, with or without
233  modification, are permitted provided that the following conditions are met:
234 
235  * Redistributions of source code must retain the above copyright notice, this
236  list of conditions and the following disclaimer.
237 
238  * Redistributions in binary form must reproduce the above copyright notice,
239  this list of conditions and the following disclaimer in the documentation
240  and/or other materials provided with the distribution.
241 
242  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
243  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
245  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
246  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
247  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
248  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
249  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
250  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
251  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
252  </PRE></BLOCKQUOTE>
253 
254  \subsection license_tem Template
255  A template for The BSD 2-Clause License are available from the
256  Open Source Initiative and Wikipidia<BR>
257  http://opensource.org/licenses/BSD-2-Clause<BR>
258  https://wikipedia.org/wiki/BSD_licenses<BR>
259 
260  \page release_page Release history
261  \section release_sec Release history
262 
263  \subsection version185 1.8.5 August 07 2018
264  - Fix build on compilers with broken endian detection.
265 
266  \subsection version184 1.8.4 August 05 2018
267  - Ignore casing in hexadecimal numbers.
268 
269  \subsection version183 1.8.3 July 21 2017
270  - Updated help texts and man page.
271  - Fixed bug in ANSI switch.
272 
273  \subsection version182 1.8.2 July 14 2017
274  - MIPS support.
275  - Improved endianness detection.
276  - Fixed configuration errors.
277 
278  \subsection version181 1.8.1 April 22 2017
279  - OpenBSD support.
280  - Fixed Haiku bug.
281 
282  \subsection version180 1.8.0 April 13 2017
283  - Fixed bugs in numeral systems.
284  - Fixed bugs related to infinity (Inf).
285  - Fixed bugs related to Not a Number (NaN).
286  - Updated and cleanup documentation.
287  - Cleaned up code structure.
288  - OpenLibm support.
289 
290  \subsection version171 1.7.1 March 26 2017
291  - Haiku support.
292  - Unified ANSI console.
293  - Code cleanup.
294 
295  \subsection version170 1.7.0 March 12 2017
296  - Introduced scientific notation.
297  - Introduced Not a Number (NaN).
298  - Fixed bugs related to infinity (Inf).
299  - Fixed bugs in log of complex numbers.
300  - Fixed bugs in numeral systems.
301  - Miscellaneous minor bug fixes.
302  - Early trigonometric functions.
303  - Static and dynamic libraries.
304 
305  \subsection version164 1.6.4 February 04 2017
306  - Fixed Windows memory bugs.
307  - Fixed 64 bit memory bugs.
308 
309  \subsection version163 1.6.3 January 30 2017
310  - Improved error handling.
311  - Fixed error in fraction point parsing.
312  - Fixed typo in help text.
313  - 64 bit PowerPC support.
314  - Fixed AROS build errors.
315  - Fixed ARMv6 build errors.
316  - Fixed 64 bit ARM build errors.
317  - Debian support.
318  - NetBSD support.
319 
320  \subsection version162 1.6.2 January 24 2017
321  - Fixed bug in memory allocation.
322  - Fixed bug in native keyboard input.
323  - Included build options in executables.
324  - ARM support.
325 
326  \subsection version161 1.6.1 January 21 2017
327  - Fixed language bug in Windows.
328  - Fixed potential memory bugs.
329  - Clang compiler support.
330  - Update copyright texts.
331  - New doxygen documentation.
332 
333  \subsection version160 1.6.0 April 7 2016
334  - Complete internal restructure of source code.
335  - Fixed several minor bugs in calculation.
336  - Support for Windows & Linux.
337  - Custom memory handling.
338  - Localization support.
339 
340  \subsection version154 1.5.4 March 04 2015
341  - Fixed several bugs in output of significant digits.
342  - Fixed sign bug in addition of negative complex numbers.
343  - Fixed sign bug in inverse hyperbolic cosine of complex numbers.
344  - Fixed sign bug in inverse hyperbolic secant of complex numbers.
345  - Fixed calculation bug in division of real number with complex number.
346  - Fixed calculation bug in exponentiation with complex number.
347  - Implemented reduction of unary sign in expressions.
348  - Implemented reduction of complex numbers in expressions.
349  - Implemented internal optimization of expression trees.
350  - Miscellaneous internal code optimization.
351  - Changed to Amiga hosted GCC compiler (ADE).
352  - Verified calculation through 192 test cases.
353 
354  \subsection version153 1.5.3 October 26 2014
355  - Changed iconed versions to run directly from Workbench.
356  - Reconfigured builds to avoid erroneous calculations.
357  - Removed broken support for numeral systems.
358  - Switched to new floating output library.
359  - Reintroduced 68020 FPU and 68030 version.
360 
361  \subsection version152 1.5.2 October 11 2014
362  - Modified character handling code to comply with licenses.
363  - Modified complex math code to comply with licenses.
364  - Modified code base to work with Kickstart 2.04.
365  - Square root of negative numbers now yield correct result.
366  - Implemented scientific notation of numbers.
367  - Infinity is now shown in division with 0.
368  - Fixed bug in number code sometimes yielding 0.
369  - Switched to Amiga memory allocation.
370  - Fixed out-of-memory bug.
371  - Miscellaneous bug fixes.
372  - Removed dead code.
373  - Added icons.
374 
375  \subsection version151 1.5.1 September 28 2014
376  - Improved navigation with arrow keys.
377  - Improved text and color compositions.
378  - Implemented missing complex functions.
379  - Fixed bug in negative complex numbers.
380  - Fixed file I/O bug in shell mode.
381  - Fixed shell flush bug on AROS.
382  - Fixed clear console bug on AROS.
383  - Miscellaneous minor bug fixes.
384 
385  \subsection version150 1.5.0 September 21 2014
386  - Calculation with complex numbers.
387  - Fixed command line version.
388  - Miscellaneous bug fixed.
389  - Fixed spelling mistakes in help files.
390  - Documentation including class diagrams in HTML format.
391  - Scripts for porting and building the source.
392 
393  \subsection version140 1.4.0 August 24 2014
394  - New math engine based on Sun Microsystems fdlibm (64 bit IEEE 754).
395  - Support for positional numeral systems including binary, octal and hexadecimal.
396  - Added pure command line version (CLI) as addition to the stand-alone version.
397  - Added statement to clear all in-memory variables and functions.
398  - Fixed bug causing console to close when entering an empty statement.
399  - Fixed bug causing application to hang when loading files with KS 2.0.4.
400  - Fixed accuracy bug when using pi and e.
401  - Restructured and improved built-in help.
402  - Added new 68030 and FPU versions.
403 
404  \subsection version132 1.3.2 August 11 2014
405  - Fixed two severe bugs causing memory corruption.
406 
407  \subsection version131 1.3.1 August 08 2014
408  - AROS i386 version released.
409 
410  \subsection version130 1.3.0 August 06 2014
411  - All trigonometric and hyperbolic functions are now supported.
412  - Runs in console window. amath no longer depends on a shell.
413  - Hardened code. amath is no longer a beta version.
414  - Added support for disk based activities.
415  - Fixed bug in exponentiation operator.
416  - Reverted back to clib math.
417  - Fixed a few memory leak bugs.
418  - Optimized generated binaries.
419  - Comments added in source code.
420  - Improved error handling.
421  - Improved built-in help.
422  - Simplified license.
423 
424  \subsection version12b 1.2b July 21 2014
425  - Root functions added.
426  - User defined functions added.
427  - Improved error handling.
428  - Improved build-in help.
429  - Binary support for additional processors.
430  - Miscellaneous bug fixes.
431  - Source files restructured.
432 
433  \subsection version11b 1.1b July 13 2014
434  - Minor bug fixes.
435  - Source code released.
436 
437  \subsection version10b 1.0b July 11 2014
438  - First public release.
439 */
440 
441 extern class Program* Program;
Master control class.
Definition: program.h:55