wcalc  2.5
About: Wcalc is a natural-expression command-line calculator.
  Fossies Dox: wcalc-2.5.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
wcalc Documentation

Some Fossies usage hints in advance:

  1. To see the Doxygen generated documentation please click on one of the items in the steelblue colored "quick index" bar above or use the side panel at the left which displays a hierarchical tree-like index structure and is adjustable in width.
  2. If you want to search for something by keyword rather than browse for it you can use the client side search facility (using Javascript and DHTML) that provides live searching, i.e. the search results are presented and adapted as you type in the Search input field at the top right.
  3. Doxygen doesn't incorporate all member files but just a definable subset (basically the main project source code files that are written in a supported language). So to search and browse all member files you may visit the Fossies wcalc-2.5.tar.gz contents page and use the Fossies standard member browsing features (also with source code highlighting and additionally with optional code folding).
README
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