Last updated January 9, 2000. See the PawSoft Web Page for information on the latest version, or send e-mail to pawsoft@mail.com. Comments or bug-reports are welcome.
PawCalc is a scientific programmable calculator for the PalmOS 2.0. Copyright © 1999, 2000 Poul Williams. All Rights Reserved.
PawCalc's main features are:
PawCalc 0.9.04 beta is distributed as freeware. Please read the LICENSE file before you install PawCalc.
[Top]Before you install PawCalc, make sure that:
PawCalc and MathLib are distributed as standard PRC files. Install "PawCalc.prc" and "MathLib.prc" like regular application programs using your favorite install tool, for example HotSync for Windows.
To use PawCalc as your default calculator:
The main window in PawCalc consists of a number of buttons, two underlined lines for entering mathematical expressions, a field for displaying the results, and four popup lists.
PawCalc accepts mathematical expressions in the standard methematical notation -- slightly adapted due to the character-based interface. Press the EXE button to evaluate an expression.
Example:The popup list just above the '/' button gives you access to the last 25 expressions.
This subsection describes each button. Some of them have obvious functions, like the '0'-'9' buttons. The rest are explained here:
Button | Description |
/ * - + | Insert the corresponding operator. If this is the start of an expression, 'ans' is inserted first. |
C | Clear the current expression. |
ans | Insert the text 'ans' -- 'ans' is a variable containing the value of the last expression. |
~ | Monadic minus -- the same as the '-' button except that 'ans' is never inserted. |
<- | 'Backspace' |
^ | Raise to a power (2^3 = two to the power of three = 8). |
(blank) | Insert a space |
STO | Store the result of a calculation in a variable. |
RCL | Insert a variable in the expression. |
A variable name consists of one letter followed by zero or more letters and digits. No spaces or punctuation marks are allowed. Be careful not to name variables the same as constants or functions, as the variables would then be 'invisible'.
Use '.' as the decimal point regardless of your Palm Pilot preferences setting. Use 'e' to indicate exponentation:
Example:Binary numbers are prefixed by '0b', octal number by '0', and hexadecimal numbers by '0x'.
Example:In the top right corner of the screen you will find a popup list named 'func'. The list gives you access to a number of functions for trigonometry (with inverse and hyperbolic), logarithms, and exponentiation. You will also find miscellaneous functions like sign, absolute value, and rounding.
All functions for trigonometry work in degrees or radians depending on the settings in the preferences.
The functions 'comb(n,r)' and 'perm(n,r)' return the combinations and permutations, respectively, of r out of n.
Use '_' (underscore) to take the root of a number. For example, enter '16_2' to take the square root of 16.
PawCalc contains a series of mathematical, physical, and chemical constants. You can access the constants through the 'const' popup list located at the top of the screen. The constants are as follows:
Name | Abbr. | Value (incl. unit) |
Pi | pi | 3.14159265358979323846264338327950 |
e | e | 2.71828182845904523536028747135266 |
Euler's Constant | euler | 0.57721566490153286061 |
Golden Ratio | golden | 1.61803398874989484820458683436564 |
Bohr Radius | a0 | 0.529177249e-10 m |
Speed of Light in Vacuum | c | 299792458 m/s |
Coulomb Constant | Cc | 8.9875517873682e9 N m²/C² |
Permittivity of a Vacuum | e0 | 8.8541878176204e-12 F/m |
Elementary Charge | ec | 1.60217733e-19 C |
Faraday's Constant | F | 96485.309 C/mol |
Earth Acceleration due to Gravity | g | 9.80665 m/s2 |
Gravitational Constant | Gc | 6.67259e-11 Nm²/kg² |
Planck's Constant | h | 6.6260755e-34 J/Hz |
Boltzmann's Constant | k | 1.380658e-23 J/K |
Permeability of a Vacuum | µ0 | 1.2566370614359e-6 N/A² |
Mass of an Electron | Me | 9.1093897e-31 kg |
Mass of a Proton | Mp | 1.6726231e-27 kg |
Mass of a Neutron | Mn | 1.6749286e-27 kg |
Avogadro's Constant | Na | 6.0221367e23 mol-1 |
Molar Gas Constant | R | 8.314510 J/(mol*K) |
Rydberg's Constant | Rinf | 1.0973731534e7 m-1 |
Atomic Mass Unit | u | 1.6605402e-27 kg |
The 'unit' popup list at the top of the screen gives access to conversions between around a hundred different units. The units are grouped in the following categories: Angle, Area, Energy, Length, Power, Pressure, Speed, Temperature, Time & Frequency, Volume, and Weight & Force.
Example:
In each unit category, a base unit is chosen. The base unit is chosen from the SI system of units. All units are converted to and from the base unit. For example, the base unit for length is meter. So, to convert from 5 km to miles, we first convert 5 km to 5000 m and then convert the 5000 m to (approx.) 3.106856 miles.
PawCalc uses the following units and conversions:
Angle ----- Base unit: rad radian rad 1 rad exact degree deg pi/180 rad exact minute min pi/(180*60) rad exact second s pi/(180*60*60) rad exact revolution rev 2*pi rad exact Area ---- Base unit: m² square mm mm² 1e-6 m² exact square cm cm² 1e-4 m² exact square meter m² 1 m² exact square km km² 1e6 m² exact square inch in² 0.00064516 m² exact square foot ft² 0.09290304 m² exact square yard yd² 0.83612736 m² exact square mile mi² 2589988.110336 m² exact acre acre 4046.8564224 m² exact hectare ha 10000 m² exact Energy ------ Base unit: J Joule J 1 J exact calorie cal 4.184 J exact horsepower hour hph 2.68452e6 J approx kilo Watt hour kWh 3.6e6 J exact British thermal unit btu 1054.35 J approx electronvolt eV 1.6021917e-19 J approx Length ------ Base unit: m nanometer nm 1e-9 m exact micrometer µm 1e-6 m exact millimeter mm 0.001 m exact centimeter cm 0.01 m exact meter m 1 m exact kilometer km 1000 m exact inch in 0.0254 m exact foot ft 0.3048 m exact yard yd 0.9144 m exact mile mi 1609.344 m exact Ângström  1e-10 m exact nautical mile (int'n.) INM 1852 m exact astronomic unit AU 1.49597870e11 m approx parsec pc 3.08572e16 m approx lightyear ly 9.46055e15 m approx Power ----- Base unit: W Watt W 1 W exact Joule per second J/s 1 W exact kilo Watt kW 1000 W exact calorie per second cal/s 4.184 W exact horsepower (mechanical) hp 745.700 W approx btu per hour btu/h 0.292875 W approx Pressure -------- Base unit: bar bar bar 1 bar exact millibar mbar 0.001 bar exact Pascal Pa 1e-5 bar exact hecto Pascal hPa 0.001 bar exact atmosphere atm 1.01325 bar exact pound force pr sq. in. psi 1/14.5038 bar approx mmHg (at 0 degree C) mmHg 0.00133322 bar approx inHg (at 0 degree C) inHg 0.0338638 bar approx Speed ----- Base unit: m/s meter per second m/s 1 m/s exact kilometer per hour km/h 1/3.6 m/s exact mile per hour mph 0.44704 m/s exact foot per second ft/s 0.3048 m/s exact knot knot 1852/3600 m/s exact Temperature ----------- Base unit: K Kelvin K 1 K exact Celsius °C °C = K - 273.15 exact Fahrenheit °F °F = 9/5 * °C + 32 exact Time / Frequency ---------------- Base unit: s nano second ns 1e-9 s exact micro second µs 1e-6 s exact milli second ms 1e-3 s exact second s 1 s exact minute min 60 s exact hour h 60*60 s exact day d 24*60*60 s exact week week 7*24*60*60 s exact year (calender) year 365*24*60*60 s exact Hertz Hz Hz = 1/s exact kilo Hertz kHz kHz = 1e-3 / s exact mega Hertz MHz MHz = 1e-6 / s exact giga Hertz GHz GHz = 1e-9 / s exact Volume ------ Base unit: l liter l 1 l exact cubic meter m³ 1000 l exact milliliter ml 0.001 l exact cubic centimeter cm³ 0.001 l exact cubic inch in³ 0.016387064 l exact cubic foot ft³ 28.316846592 l exact cubic yard yd³ 764.554857984 l exact bruttoregisterton BTR 2831.6846592 l exact fluid ounce floz 1/33.814023 l approx pint pt 0.4731632 l approx quart qt 0.9463264 l approx gallon (US) gal 3.7854118 l approx barrel (42 US gallons) bbl 158.98284 l approx cup cup 0.2365816 l approx tablespoon tbsp 0.01478635 l approx teaspoon tsp 0.004928783 l approx Force & Weight -------------- Base unit: kg milligram mg 1e-6 kg exact gram g 0.001 kg exact kilogram kg 1 kg exact metric ton t 1000 kg exact short ton (2000 lb) ton 907.18474 kg exact UK (long) ton (2240 lb) UKton 1016.0469088 kg exact grain (1/7000 lb) grain 0.00006479891 kg exact ounce oz 0.028349523125 kg exact pound (16 oz) lb 0.45359237 kg exact atomic mass unit amu 1.6605402e-27 kg approx Newton N 1/9.80665 kg exact dyne dyn 1/9.980665e5 kg exact kilogram force kgf 1 kg exact pound force lbf 0.45359237 kg exact
PawCalc considers a value of zero to be false and any other value to be true. When returning a truth value, PawCalc always uses zero for false and one for true.
You can compare values using =, <, >, <>, <=, and >=.
You can program PawCalc in a simple imperative language. Write your programs in the build-in Memo Pad application. Place them in a category named "PawCalc". You can write up to 5 programs.
A program consists of a head and a body. The head consists of the program name and a list of parameter variables. The body is enclosed in curly brackets ('{' and '}') and it consists of a number of program statements.
There are two types of variables: local and global. Local variables are only known within the scope of a program. Global variables are known across programs. In case of a name conflict between local and global variables, the local variable is used.
PawCalc understands the following program statements:
local ID; # declare a local variable local ID := EXP; # declare a local variable and assign it a value global ID; # declare a global variable gloabl ID := EXP; # declare a global variable and assing it a value return EXP; # end program and return with expression let ID := EXP; # assign expression to variable while EXP do # while expression is true do STATEMENTS # execute these statements endwhile # endwhile repeat # repeat STATEMENTS # the statements until EXP; # until expression is true if EXP then # if expression is true STATEMENTS # execute these statements elsif EXP then # else if expression is true STATEMENTS # execute these statements else # else STATEMENTS # execute these statements endif # endif
Below are examples are programs. Place them in the PawCalc category in your Memo Pad application. Run them by typing their name and argument list.
Example:Compounded interest calculation program:
ci( capital, procent, year ) { return capital*(1 + procent/100)^year; }
Present value calculation program:
pv( capital, procent, year ) { return capital / ((1 + procent/100)^year); }
Annuity calculation program:
an( capital, procent, year ) { local p := procent/100; local t := (1+p)^year; return capital * t * p / ( t - 1 ); }
Inflation calculation program:
in( procent ) { return 100*procent / ( 100 + procent ); }
There are a couple of limitations for programs in PawCalc:
You can set the preferences by selecting the menu edit|preferences. Here you can set the number of digits after the decimal point (0-9) and the display mode (normal, scientific, or engineering). You can choose to remove trailing zeros when displaying results. These options only affect the way PawCalc displays numbers. All calculations are performed with the full precision. This also applies to the 'ans' variable, which contains the last result with full precision.
Furthermore, you can toggle between degrees and radians for trig functions.
NB: At most 14 digits in total are displayed for a result.
PawCalc uses IEEE 754 double precision numbers. This gives PawCalc a precision of around 14 digits, and exponents in the range -300 to +300.
Take care to stay within these limits. This also applies to intermediate calculations such as the implicit conversion to and from base units in unit conversions. For example, to convert from parsec to lightyears, it is enough to multiply by approximately 3.26. However, PawCalc converts from parsec to meters and then from meters to lightyears resulting in multiplication by 3.08e16 and then division by 9.46e15.
Not all real numbers have a IEEE 754 representation. Instead such real numbers are approximated by the nearest IEEE 754 number. Such approximations lead to small errors. For example, the decimal representation of the fraction 1/7 is 0.142857142857... where 142857 repeats forever. Try calculating "1/7-0.142857142857". The result is 1.42857948e-13. The last three digits are 948 and not 142.
After evaluating an expression, PawCalc writes the result on the screen. In case of a syntactical error, PawCalc displays the string 'Error'. 'NaN' is short for Not-a-Number and is used if the result is not a real number (as in the square root of negative numbers). In case of overflow, "+Inf" or "-Inf" is displayed representing plus and minus infinity.
[Top]MathLib is a free shared library that can be used by any OS 2.0+ Pilot program that needs IEEE 754 double precision math functions. It's distributed under the terms of the GNU Library General Public License, and is freely available with full source code and documentation at the MathLib Information web page. It's not a part of the PawCalc program, and you're not paying anything for its use; a copy is simply included in this distribution for your convenience.
[Top]The error messages might not be the best.
In some cases, the trig functions return results that are slightly off. For example, in degree mode, 'sin 360' is not 0 but -1.133e-15.
Expressions are evaluated from left to right. Because of the limited precision, 1+1e-10-1 is not equal 1-1+1e-10.
It is possible to create 'hidden' variables by naming them the same as constants and functions. No check is performed to disallow this.
[Top]Version 0.9.04 beta, January 9, 2000:
Version 0.9.03 beta, December 21, 1999:
Version 0.9.02 beta, December 11, 1999:
Version 0.9.01 beta, September 21, 1999: Fixed errors in the display function.
Version 0.9 beta, August 30, 1999: First beta release.
[Top]