Reverse Polish Notation and Expression Calculator
This is rather old (made in 2003) as it is based on the old keypad based cellphones with WAP pages of the 00s. With modern touchscreen browsers on both computers and smartphones, you can ignore the 'phonebrowser' text.
Features:
- Uses both RPN and expressions.
- Predefined expressions can be made in a separate javascript file.
- All numbers on the stack and display mode statuses are saved in local storage after each calculation and restored when the browser reopens this page.
- Works on all browsers as long as they support javascript. Even on small phone browsers supporting javascript
- Phone keypad mode which allows displaying a keypad layout on phones with and without touchscreen.
- As a fun feature can be used in all radixes from 2 to 36. With command line option a=1 the letters 'I' and 'O' will be included and no '@' and '#' will be used for the numerals 34 and 35.
An example: Suppose you want calculate 5 * (3 + 4)
Press the following keys on the calculator: 5, enter, 3,
enter. The 3 and 5 did go into the calculator's memory, the
stack. Now you type 4 and press + to add. After this you just
press * to multiply.
Besides it accepts expressions using the four base operators and the most used math functions.
You can either operate this calculator with mouse clicks or you can use the keyboard. However some web-browsers have keyboard shortcuts which may conflict with the keys used by this calculator. Therefore you need to give focus to the button above the stack display when using the keyboard as this avoids the browsers keyboard shortcuts to take effect. Even then, some browsers (e.g. Opera) the backspace key lets return the browser to the previous page rather than backspacing the input. The keyboard interface was tested with Mozilla Firefox 2.0 and 3.0, MS IE 6 and 7 and Opera 9.6. Furthermore it is tested on mobile browsers like Opera Mobile 8.65 and the native(gecko) browser on a Nokia smartphone. In the latter case, set to single keystroke mode.
There are three modes of operation which start automatically dependant on the user agent. But these can be enforced by command line options.
- p=1: Phone keypad which relies heavily on a phone keypad with the keys 1,2,3,4,5,6,7,8,9,*,0,# and backspace (C) keys. Pressing the star (*) key will show operators and functions which can be enabled by pressing the appropiate digit key. Pressing the # key results in subsequently - (minus), decimal point and if there is already a point, an exponent sign (e).
Note: in some browsers the keyboard capture won't work. E.g pressing backspace terurns to the revious page in Opera. I may help that you click on the green bar above the display. - p=2: Phone keypad but with clickable' keys suited for touchscreen phones such as the iPhone which allows entering numbers and operations by clicking. On desktop browsers it are just mouseclicks.
- q=1: Desktop version keypad can also be used on phone browser which allows 'normal' keys (e.g. on QWERTY keyboard devices). As some browsers do not allow the enter and backspace keys to be redefined, there are backspace and enter buttons. The 'new number' key allows to enter a number or an expression.
You can enter a number in the following ways: Date and angle input:
- -00dd.mmsssxxx Enter an angle in degrees, minutes and seconds starting with two zeroes (optionally preceded by a minus sign), will be convertied to a decimal value.
Note, when converting entire degrees, use a decimal sign behind it e.g. 0012. converts to 12 degrees, but 0012 converts to timestamp 12 seconds fter 1 jan 1970 (see below). - 000dd.mmsssxxx Enter an angle in hours, minutes and seconds starting with three zeroes (optionally preceded by a minus sign), will be convertied to a decimal value and multiplied by fifteen (e.g. for entering hour angles). E.g. 00023.30 will result in 352.5 degrees.
- 0yyyymmdd.hhmmsssxxx Enter two zeroes, a (4 digit) year, two digits month and two digits day (optionally followed by hours, minutes and seconds) will result in a Julian date. E.g. 020060506.18 results in 2453862.75 . This makes date calculations easy: 020070226 [enter] 020060226 [-] results in 365.
- 00xxxxxxxx (with optional minus sign before it, NO decimals) returns the JD of a given Unix timestamp (seconds since 1 jan 1970).
- 00 returns today's JD with time fraction and 000 only an integer JD.
Other radixes than 10 can be used, not only octal and hexadecimal but all radixes from 2 to 34. All letters except I and O (confusion with 1 and 0) are used
so this allows a maximum radix of 10 + 24 = 34. All functions remain available, including math. When using option a=1 in the browser address bar, all letters are supported (also I and O) which allows radixes up till 36. When the radix is above ten (e.g. hexadecimal) numerals of ten and higher (A,B,C,...) must be entered by UPPERCASE letters. In phone keypad mode just repeatedly press the key with the proper characters, e.g. press the '3' key four times to get an hexadecimal F(ifteen), as 3DEF is stated on the key (and the physical key on most phones).
In number / expression edit mode, radixes can be overridden as well per number: a number prepended by a '0x' will be interpreted as hexadecimal, prepended by a lowercase 'd' as decimal, as appended by :nn
in radix nn when nn is expressed in decimal. E.g 10:12
will be interpreted as twelve regardless of radix.
Use the Editbox function to copy /paste values. All text will be capitalized and invalid digits ignored. A simple expression can be used. Click here for more info. More on expression usage:
- Expressions can be copied / pasted to
scicalc_expressions.js
in the format"title:::expression:::text",
(with the quotes and the trailing comma as it should be valid javascript), example:"°C->°F:::d;drop();s1*9/5+32;:::°F",
This displays once in the title the number in lower accuracy followed by [text]. The text parameter is optional. - Numbers are treated in the current radix. In the unlinkely case one needs to calculate an engineering expression with decimal constants, prepend the expression woth
d;
, then all numbers in the expression will be interpreted as decimal, regardless when in hex mode or any other radix. E.g Celsius to Fahrenheit temperature conversion can be expressed asd;drop();s1*9/5+32;
Command line options:
- k=1: do not override keyboard handing and pass all keyboard handling to the browser
- p=1: force phone keypad on desktop browser
- q=1: force desktop version keypad on phone browser which allows 'normal' keys (e.g. on QWERTY keyboard devices)
- p=2: Phone like keypad for touchscreen phones such as the iPhone which allows entering numbers and operations by clicking. On desktop browsers it are mouseclicks.
later adapted by klaas skatebiker at hot mail dot com