RPN calculator calculates even complicated terms without braces. This Reverse Polish Notation calculator uses postfix representations. It has many advantages over Algebraic notation.
Features
a) You can calculate even complicated terms without braces.
b) Used for postfix notations.
c) Provides easy accessibility to calculation.
d) Calculations can be performed by using both keyboard or mouse clicks.
e) When a number is entered, the previous entry is raised in the stack, so that several values can be stored.
Preview
RPN Calculator
Code
Javascript Code
<!-- Script by hscripts.com -->
<!-- Copyright of HIOXINDIA -->
<!-- More scripts @www.hscripts.com -->
<script type="text/javascript">
var lift = 0;
var line = "";
var x = 0;
var y = 0;
var z = 0;
var t = 0;
var arc = 0;
var mem1 = 0;
var mem2 = 0;
var mem3 = 0;
var degmode = 1;
var valpi = 3.14159265358979323846;
var degtorad = valpi / 180;
var radtodeg = 180 / valpi;
function convert()
{
if (line != "")
{ x = parseFloat(line); line = ""; }
}
function show()
{
document.rpncalc.t.value = t; document.rpncalc.z.value = z;
document.rpncalc.y.value = y; document.rpncalc.x.value = x;
}
function clearall()
{
x = y = z = t = mem1 = mem2 = mem3 = 0;
line = ""; show();
}
function clx()
{
x = 0; line = ""; show(); lift = 0;
}
function clearreg()
{
convert(); mem1 = 0; mem2 = 0; mem3 = 0; lift = 1;
}
function exchange()
{
convert(); var temp = x; x = y; y = temp; show(); lift = 1;
}
function rolldown()
{
convert(); var temp = x; x = y; y = z; z = t; t = temp; show(); lift = 1;
}
function rollup()
{
convert(); var temp = t; t = z; z = y; y = x; x = temp; show(); lift = 1;
}
function drop()
{
y = z; z = t;
}
function number1(digit)
{
if (lift) enter();
lift = 0; line += digit; document.rpncalc.x.value = line;
}
function enter()
{
convert(); t = z; z = y; y = x; show();
}
function plus()
{
convert(); x = x + y; drop(); show(); lift = 1;
}
function minus()
{
convert(); x = y - x; drop(); show(); lift = 1;
}
function times()
{
convert(); x = x * y; drop(); show(); lift = 1;
}
function divide()
{
convert(); x = y / x; drop(); show(); lift = 1;
}
function squarert()
{
convert(); x = Math.sqrt(x); show(); lift = 1;
}
function square()
{
convert(); x = x * x; show(); lift = 1;
}
function pie()
{
if (lift || (line != "")) enter();
convert(); x = Math.PI; show(); lift = 1;
}
function sqrt()
{
convert(); x = Math.sqrt(x); show(); lift = 1;
}
function setarc()
{
arc = 1;
}
function sine()
{
convert();
if (arc) x = invtrig(Math.asin(x));
else x = Math.sin(pretrig(x));
show(); lift = 1; arc = 0;
}
function cosine()
{
convert();
if (arc) x = invtrig(Math.acos(x));
else x = Math.cos(pretrig(x));
if ( x < 6.124e-17 ) { x = 0; } // cos 90 = 0
show(); lift = 1; arc = 0;
}
function tangent()
{
convert();
if (arc) x = invtrig(Math.atan(x));
else x = Math.tan(pretrig(x));
if ( x > 1633e13) { x = 1/0; } // tan 90 = Infinity
show(); lift = 1; arc = 0;
}
function natlog()
{
convert(); x = Math.log(x); show(); lift = 1;
}
function expon()
{
convert(); x = Math.exp(x); show(); lift = 1;
}
function power()
{
convert(); x = Math.pow(y, x); drop(); show(); lift = 1;
}
function recip()
{
convert(); x = 1 / x; show(); lift = 1;
}
function changes()
{
convert(); x = -x; show(); lift = 1;
}
function store()
{
convert();
if (x == 1) mem1 = y;
if (x == 2) mem2 = y;
if (x == 3) mem3 = y;
x = y; drop(); show(); lift = 1;
}
function storeadd()
{
convert();
if (x == 1) mem1 = mem1 + y;
if (x == 2) mem2 = mem2 + y;
if (x == 3) mem3 = mem3 + y;
x = y; drop(); show(); lift = 1;
}
function storeminus()
{
convert();
if (x == 1) mem1 = mem1 - y;
if (x == 2) mem2 = mem2 - y;
if (x == 3) mem3 = mem3 - y;
x = y; drop(); show(); lift = 1;
}
function recall()
{
if (lift || (line != "")) enter();
convert();
if (x == 3) x = mem3;
if (x == 2) x = mem2;
if (x == 1) x = mem1;
drop(); show(); lift = 1;
}
function percent()
{
convert(); x = x * y / 100; drop(); show(); lift = 1;
}
function clrstack()
{
convert(); t = 0; z = 0; y = 0; x = 0; show(); lift = 1;
}
function fdegrad(x)
{
degmode = x;
}
function pretrig(x)
{
if(degmode) { x *= degtorad; }
return(x);
}
function invtrig(x)
{
if(degmode) { x *= radtodeg; }
return(x);
}
function ffact()
{
convert();
var counter = x; var fct = counter;
while(--counter > 0)
{ fct *= counter; }
x = fct; show(); lift = 1;
}
function ctck()
{
var sds = document.getElementById("dum");
if(sds == null){
alert("You are using a free package.\n You are not allowed to remove the tag.\n");
}
var sdss = document.getElementById("dumdiv");
if(sdss == null){
alert("You are using a free package.\n You are not allowed to remove the tag.\n");
}
}
document.onload="ctck()";
</script>
<!-- Script by hscripts.com -->
For customization of this script or any script development, contact us at support@hscripts.com
Usage
a) Copy and paste the javascript code into your HTML page and make use of this RPN(Reverse Polish Notation)calculator.
b) This script can be used for postfix representations.
c) This script can be used to solve complicated terms without braces.
License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.