Download Latest Version crunch_beta-0.3.7.zip (37.5 kB)
Email in envelope

Get an email when there's a new version of Note Cruncher

Home / beta-0.3.7
Name Modified Size InfoDownloads / Week
Parent folder
README 2012-02-17 8.3 kB
crunch_beta-0.3.7.zip 2012-02-17 37.5 kB
Totals: 2 Items   45.8 kB 0
CRUNCH README
-----------------------------------------
Version beta-0.3.7

This calculator spawned from a desire to have a commandline calculator that starts instantly and doesn't require you to type the full word "quit" to quit.  Simply start the program, do a few calcs, and 'q' is enough to get out.  The main goal is to make this calculator cross-platform with dependencies only on c standard libraries, and make it fast starting and quitting.  At the same time, the calculator should support more advanced functions such as trig and log functions as well as binary operations, thus making it equal in features to the average desktop GUI calculator.

The goal is to fill a place between fully-featured programs such as Octave/Matlab/Maple/(name of huge math program here) and simple GUI calculators.  It is my opinion GUI's get in the way of efficiency.  When features increase, usefulness decreases.

There may be other CLI calculators out there that do what I want, but I have been left unsatisfied whith what I have tried so far--either it is too simple, or it is too cumbersome, so... why not make yet-another-cruncher exactly tailored to my preferences?

As can be seen, this is the proverbial re-invention of the wheel with a nich use, but since I'm doing it for fun as well as educational purposes, I may as well share it with whoever finds it useful.  Enjoy!


YADA YADA
---------
This is the "WOL" Wide Open License software.  You can take it, do anything with it, use it in commercial and non-commercial projects alike, assimilate it into larger projects, use it for educational purposes, or whatever else constitutes as software use, copying and distribution -- But I must attach some stipulations to cover my @77:
This software comes with NO WARRANTY of any kind, implied or otherwise.
I am not responsible for anything you do with it.  Once you take the code, you assume responsibility for all consequences related to its use.
I am not responsible for anything it does to you.  I have personal incentive to make it as accurate and bug-free as possible, but I have no obligation to do so.

Finally, I have the copyright for the code.  If you redistribute or re-use, you must retain authorship and show credit where due.  The intent is to provide protection for my ownership and the right to use and redistribute my own code.  

BUILDING AND EXECUTING
----------------------
I have included the Windows executable "crunch.exe" which you can simply download and double-click to run, should be good to go there.
Copy it to whatever folder you want.  You may also wish to make a shortcut and assign an icon to it.

For Linux, I will try to keep a binary up-to-date in the corresponding release directory, but I recommend building from source...which is really really simple for a small 1-file program without dependencies on any libraries other than standard C libs (this is one of the goals of the project). Just make sure you have gcc installed (for command below, search your package manager for g++ and install associated packages until the command works).

Just copy main.C into whatever directory you want to and do the following from that directory:
$ gcc main.c crunch.c -lm -o crunch

//if you feel the need to add compiler options, feel free, but at this time the program is so simple I don't see much need for any optimisation
//However, you may find some other options need to be included to make it compile successfully on your system.

If you want to launch it without the full directory name,  you want it in your $PATH, then as root (or using sudo),

# cp crunch /usr/sbin

or similar directory in your $PATH


Simply execute the file.

GENERAL USAGE
-------------
For details of usage, the first thing to do after starting the program is to type "help" at the prompt.

Even without help, things are very straight-forward.  Right now it supports the following operations
listed in order from lowest to highest evaluation priority:
Operator	Function
--------	--------
+		ADD
-		SUBTRACT
*		MULTIPLY
/		DIVIDE
`       HIGH PRIORITY MULTIPLY (evaluated before DIVIDE)
%		MODULO (Performs floating-point modulo, so it's good for both integers and the rest of the real numbers)
^		POWER (Example: 2^4 is 2 raised to the 4rth power)

This version supports several trigonometric functions as well as logarithms.  Here is the list:
Functions:
----------
sin()
cos()
tan()
asin()
acos()
atan()
log()
ln()
sqrt()

Something like this would do fine:
[crunch-0] $ x = 3*pi/4
x = 2.3562

[crunch-1] $ y=cos(x)
y = -0.7071


10^N Exponential Notation
-------------------------
Invoke "M*10^N" notation in the folowing manner:
MeN 
For Example, to represent 1 times 10 to the 6th,  "1e6" is the proper notation. Here are some real examples:
[crunch-0] $ 1e3
ans = 1000.0000
[crunch-1] $ 5*2e-4
ans = 0.0010

This is pretty standard, so not likely anybody will have trouble here.

Also possible is shorthand notation.
p,n,u,m,k,M,G

For example:
[crunch-0] $ 1k
ans = 1000.0000

VARIABLES
---------
You can assign variables and use them in expressions. There are no real rules about what variable names may include.  The only rule is a variable is anything in front of an equal sign and whitespace is ignored.

For example, you can get yourself into real trouble fast with variables:
[crunch-5] $ 2+3 = 5*2
2+3 = 10.0000

[crunch-6] $ 2+3/4
ans = 2.5000

Certainly if you hadn't assigned "2+3" as a variable, the expression would have evaluated to 2.75

...So be careful.  As you can see, it found the pattern "2+3" before doing any processing, then that sequence will always evaluate to 10.

However, this goes to demonstrate the freedom in variable names; you can abuse this characteristice to create
useful mnemonics in your calculation session.

As pertains to whitespace, it always eats it up:
[crunch-7] $ free lancer = 4/3
freelancer = 1.3333

If you want to use your variable "free lancer" later, you need to use freelancer or or it will more likely be ignored if there aren't other variable names "free" or "lancer".

Just keep in mind the power and the pitfalls of the free-form treatment of variable names.


ORDER OF OPERATIONS
-------------------
Proper mathematical order of operations is honored, as well as respect for parentheses groupings. 


LOG FILES 
---------
You can save your session to a text file by the following:
[crunch] $ log      //Show log state and name of file
[crunch] $ log on   //This will turn on the log
[crunch] $ log off  //stop recording to text file
[crunch] $ log f   //specify a different file name than the default -- you can run this command even when log is off,
                   //and this is the file it will use when you turn log on.

Default file is "crunch.log" saved in the directory from which the program is executed.  

INPUT ARGUMENTS
---------------
Crunch now takes input arguments from the shell:
Linux:
$ crunch cos[pi/3]*2+3/sqrt[5.5]*-7
-7.9544

Windows:
C:\Path\to\Crunch> .\crunch.exe cos[pi/3]*2+3/sqrt[5.5]*-7
-7.9544

Note: From the console use either square braces [] or curlies {} for parentheses, or mix them if you like.  Most shells process 
normal parentheses () in such a way that would require you to put double quotes "" around the whole expression.  Square braces are the fastest
to use.  You may use any of those symbols interchangeable within the regular Crunch session as well.

PREFIX MULTIPLIERS
------------------
These are the representations for both input and the meaning of the output when fmt = ON.

yocto   y       10^-24
zepto   z       10^-21
atto    a       10^-18
femto   f       10^-15
pico    p       10^-12
nano    n       10^-9
micro   u       10^-6
milli   m       10^-3
kilo    k       10^3
mega    M       10^6
giga    G       10^9
tera    T       10^12
peta    P       10^15
exa     E       10^18
zetta   Z       10^21
yotta   Y       10^24


FINAL NOTES
-----------

Comments, Suggestions and collaboration are all welcome:
ryjobil@gmail.com

REVISIONS
---------
Update: February 13, 2012
Update: December 13, 2011
Update: July 7, 2011
Update: June 15, 2011
Initial Release: June 13, 2011


 
Source: README, updated 2012-02-17