UnitCalc Reference
Basic Units
These are the ten base units built into UnitCalc. All other units are
derived from these in your prefs.txt file. The user-defined units
(u1, u2, and u1)
may be defined as whatever you want: people, molecules, roads, etc.
- m (meters -- length)
- sec (seconds -- time)
- g (grams -- mass)
- c (coulombs -- charge)
- deg (degrees -- temperature)
- cd (candles -- luminous intensity)
- $ (dollars -- money)
- u1 (user's unit 1 -- anything)
- u2 (user's unit 2 -- anything)
- u3 (user's unit 3 -- anything)
Unit Prefixes
UnitCalc understands the 14 standard prefixes in the metric system, as shown
in the tables below. Note that each prefix uses a single letter (e.g., deka
is "D" rather than "da") and a few prefixes have two equivalent forms (K, k).
Prefix |
T |
G |
M |
K or k |
H or h |
D |
---|
Name |
tera |
giga |
mega |
kilo |
hecto |
deka |
---|
Factor |
10^12 |
10^9 |
10^6 |
10^3 |
10^2 |
10 |
---|
Prefix |
d |
c |
m |
µ or u |
n |
p |
f |
a |
---|
Name |
deci |
centi |
milli |
micro |
nano |
pico |
femto |
atto |
---|
Factor |
10^-1 |
10^-2 |
10^-3 |
10^-6 |
10^-9 |
10^-12 |
10^-15 |
10^-18 |
---|
Built-In Functions
At the "in:" prompt, you can either type a quantity (like 42 m
sec^-1) to go on the stack, or the name of a function, which
performs some operation on the stack. The built-in functions are:
- pop -- deletes the top item on the stack.
- swap -- swaps the position of the top item
and the next item on the stack.
- dup -- duplicates the top item on the stack.
- clear -- empties the stack.
- on -- turns on use of preferred units.
- off -- turns off preferred units, and displays
all quantities in basic units.
- load (filename) -- executes a script; filename
defaults to unitcalc.rc.
- save (filename) -- writes a script; filename
defaults to unitcalc.rc.
- +, -, *,
/, ^ -- performs
addition, subtraction, multiplication, division,
and exponentiation of the top two items on the stack
- 1/ -- multiplicative inverse of top item on the stack.
- 0- -- additive inverse of top item on the stack.
- =varname -- assings the top item on the stack
to variable varname. "varname" may be any string up
to 20 characters long, with no whitespace.
- varname -- puts the variable (with its value)
on the stack.
- use -- use the variable on the top of the
stack as a preferred unit.
- use <var> -- use <var> as a preferred unit.
UnitCalc Scripts
With version 0.5, UnitCalc has the ability to read commands from a
text file. These are executed just as if you had typed them.
The main use for this is to define derived units and variables you
want UnitCalc to use. When UnitCalc starts, it looks for a file
called unitcalc.rc
in the current directory. If it finds such a file, it is read as
a script. The standard unitcalc.rc
defines common SI and American derived units; you may wish to
customize which ones are used in output, or remove
the American units altogether.
There are two ways to create a script:
- Enter variables and preferences (via use) in
UnitCalc, then use the save command.
- Directly create or modify a script with your favorite text editor.
There are also two ways scripts get executed:
- If a file name unitcalc.rc exists, it is executed when UnitCalc
is started.
- You can execute a script at any time with the load
command.
NOTE: The new script function replaces the prefs.txt
file that was formerly used to define preferred units. prefs.txt
is no longer used.
Multiple Commands on One Line
You can give multiple functions or values on a line. Simply separate
them by tabs, commas, vertical bars, or newlines (i.e. the Return key,
which is the usual situation).