File: README

package info (click to toggle)
wcalc 2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,284 kB
  • sloc: ansic: 8,379; sh: 2,250; objc: 1,776; lex: 852; yacc: 603; makefile: 127
file content (147 lines) | stat: -rw-r--r-- 5,805 bytes parent folder | download | duplicates (2)
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
Hello!

This is Wcalc 2.5!

1. What's New
2. Intro
3. Installation
4. License
5. Known Bugs
6. Contact Info

**************
* What's New *
**************

CHANGES:
 - Color support!
 - Generic SI unit conversion!

IMPROVEMENTS:
 - Improved documentation
 - Increased precision for e constant
 - More robust prefs parsing
 - Prettier list output
 - Better detection of libreadline variants
 - Support for newer versions of autotools
 - Support for \assert command
 - Automatic testing infrastructure (via `make check`)

BUGFIXES:
 - Fix 0 parsing bug (2.4.1 regression; thanks Arun Prakash Jana!)
 - Plugged memory leaks
 - Fixed segfault when parsing hierarchical expressions
 - Fixed handling of Euler constant

*********
* INTRO *
*********

Wcalc started as a project written for my C++ class at Ohio University (CS 240B), way back on January 14th, 2000. I made it to be a "natural language" calculator - in that it would successfully interpret any valid mathematical expression. As you can imagine, being a beginner programmer, the code was rather heinous, to say the least!

I reworked it after learning lex and yacc (powerful string parsing tools for C programmers - if you're a C programmer and you don't know them... go google!) in November 2001. Then I thought to myself - I have MacOS X, the standard calculator leaves something to be desired, and they say Cocoa programming is easy... what the heck, I'll give it a shot. Wcalc, the GUI version, turned out to be a pretty neat calculator. The GUI version, however, has been abandoned in favor of the CLI.

Wcalc takes "expressions" and calculates the answer. My goal was to make the expressions relatively intutive - no reverse polish, or anything like that. So, by way of a record, here is what Wcalc can do:

**********
* Syntax *
**********

Wcalc recognizes the following symbols:
+ (plus)
- (minus)
* (multiply)
/ (divide)
% (modulo (read: the remainder when integers are divided))
! (factorial or boolean NOT)
^ (exponent. four squared is 4^2)
< (less than)
> (greater than)
<= (less than or equal to)
>= (greater than or equal to)
== (equal)
!= (not equal)
&& (logical and)
|| (logical or)
<< (bitshift left)
>> (bitshift right)
| (bitwise or)
~ (bitwise not)
& (bitwise and)

Wcalc also allows you to group operations with parenthesis (), brackets [], and braces {}.

Wcalc supports the following functions:
sin cos tan cot asin acos atan acot
sinh cosh tanh coth asinh acosh atanh acoth
log ln logtwo round abs ceil floor sqrt cbrt comp
Gamma lnGamma zeta sinc

Wcalc has a few built-in constants:
e pi Na k Cc ec R G g Me Mp Mn Md u amu c h mu0 epsilon0
muB muN b a0 F Vm NAk eV sigma alpha gamma re Kj Rk Rinf
Eh Gf Mmu Mt Mh Malpha n0 c1 c2 G0 Phi0 K
random irandom rand irand

Wcalc supports user-defined variables. You define a variable like this:
mynewvariable=5
Then you can use it in an expression like this: 1+3*mynewvariable/4

You can also define "active" variables. When you assign a variable, put it in single-quotes, like this:
twicepreviousanswer='a * 2'
In expressions, these work just like regular variables, except the value is calculated when it's used, not when it's defined.

Some special notes about variables - two letters are reserved:
a - this variable represents the last answer, and may be used in expressions.
q - this variable is reserved in the command-line version (it means quit), and cannot be used in expressions.
Also, built-in constants cannot be re-defined, although they are treated as variables in all other cases.

*********
* Bases *
*********

When you type a number into Wcalc, the number is normally assumed to be in decimal form. However, if the number has a prefix, it may be interpreted as a different form number. Specifically:

0x - this means "the following is a hexadecimal"
0 - this means "the following is octal"
0b - this means "the following is binary"

This prefix affects only the number it prefixes, and none of the other numbers in the expression.

Answers are, by default, displayed in decimal form. This can be changed in the preferences window - and display of the prefixes can be toggled in the preferences window as well. You can also change the display using the \hex, \oct, \bin, or \dec commands.

You can, however, print a number in any base (without a prefix) by using the \base command.

****************
* Installation *
****************

There are pre-built packages available for download for several Linux and BSD  distributions. Otherwise, the source for Wcalc is available on SourceForge from the Wcalc home page. Install as you would usually install from source. If you're really new to this sort of thing, there's some information in the INSTALL file.

***********
* License *
***********

Wcalc is made available under the GNU Public License (GPL), version 2, or (at
your option) any later version of that license. The full text of the License is
in the file titled COPYING as distributed with the source, or is available
here: http://www.gnu.org/copyleft/gpl.html

The general gist of the GPL is this: This program is free. You may do as you like with it, including sell the binaries, as long as you don't modify the program or use it as part of another program. If, however, you download the source code of this program and either modify the source (and give it to people) or use pieces of the source in your own program (and give THAT to people), you must distribute that program and its source code under the GPL as well.

**************
* Known Bugs *
**************

The grammar has too many shift/reduce conflicts.
Leaks memory when there's a parse error.

If you find more bugs, please LET ME KNOW!

****************
* Contact Info *
****************

The Wcalc homepage is http://w-calc.sourceforge.net/

Contact me at kyle-wcalc-sf@memoryhole.net