Type Here to Get Search Results !

Welcome To FreeSiteTools

RPN (Reverse Polish Notation) Calculator Tool Code


<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 = 0show(); 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 = Infinityshow(); 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>



<body onLoad = "clearall()">

<center><h2>Javascript RPN Scientific Calculator</h2>

<form name="rpncalc">

<table border=1 width="500px" bgcolor="#c3d9ff">

<tr><td colspan=5><table align=center bgcolor="#ffffcc"><tr><td>T : </td><td><input name="t" type="text" size="30" value="0"></td></tr><tr><td>Z : </td><td><input name="z" type="text" size="30" value="0"></td></tr><tr><td>Y : </td><td><input name="y" type="text" size="30" value="0"></td></tr><tr><td>X : </td><td><input name="x" type="text" size="30" value="0"></td></tr></table>

</td></tr>

<tr align="center"><td><input type="button" value="x !" onClick="ffact()"><td colspan="2"><input type="radio" checked name="degrad" onClick="fdegrad(1)">Degrees<td colspan="2"><input type="radio" name="degrad" onClick="fdegrad(0)">Radians

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value="ln" onClick="natlog()"><td><input type="button" style="width:60px;" value="e^x" onClick="expon()"><td><input type="button" style="width:60px;" value="y^x" onClick="power()"><td><input type="button" style="width:60px;" value="1/x" onClick="recip()"><td><input type="button" style="width:60px;" value="%" onClick="percent()">

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value="pi" onClick="pie()"><td><input type="button" style="width:60px;" value="arc" onClick="setarc()"><td><input type="button" style="width:60px;" value="sin" onClick="sine()"><td><input type="button" style="width:60px;" value="cos" onClick="cosine()"><td><input type="button" style="width:60px;" value="tan" onClick="tangent()">

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value="rup" onClick="rollup()"><td><input type="button" style="width:60px;" value="chs" onClick="changes()"><td><input type="button" style="width:60px;" value="x<>y" onClick="exchange()"><td><input type="button" style="width:60px;" value="x^2" onClick="square()"><td><input type="button" style="width:60px;" value="sqrt" onClick="squarert()">

</tr>

<tr align="center">

<td><input type="button" style="width:60px;" value="rdn" onClick="rolldown()"><td><input type="button" style="width:60px;" value="clrg" onClick="clearreg()"><td><input type="button" style="width:60px;" value="clst" onClick="clrstack()"><td><input type="button" style="width:60px;" value="clx" onClick="clx()"><td><input type="button" style="width:60px;" value="enter" onClick="enter()">

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value=" 7 " onClick="number1('7')"><td><input type="button" style="width:60px;" value=" 8 " onClick="number1('8')"><td><input type="button" style="width:60px;" value=" 9 " onClick="number1('9')"><td><input type="button" style="width:60px;" value=" + " onClick="plus()"><td><input type="button" style="width:60px;" value="sto+" onClick="storeadd()">

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value=" 4 " onClick="number1('4')"><td><input type="button" style="width:60px;" value=" 5 " onClick="number1('5')"><td><input type="button" style="width:60px;" value=" 6 " onClick="number1('6')"><td><input type="button" style="width:60px;" value=" - " onClick="minus()"><td><input type="button" style="width:60px;" value="sto-" onClick="storeminus()">

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value=" 1 " onClick="number1('1')"><td><input type="button" style="width:60px;" value=" 2 " onClick="number1('2')"><td><input type="button" style="width:60px;" value=" 3 " onClick="number1('3')"><td><input type="button" style="width:60px;" value=" * " onClick="times()"><td><input type="button" style="width:60px;" value="sto" onClick="store()">

</tr>

<tr align="center"><td><input type="button" style="width:60px;" value=" 0 " onClick="number1('0')"><td><input type="button" style="width:60px;" value=" . " onClick="number1('.')"><td><input type="button" style="width:60px;" value="eex" onClick="number1('e')"><td><input type="button" style="width:60px;" value=" / " onClick="divide()"><td><input type="button" style="width:60px;" value="rcl" onClick="recall()">

</tr>

<tr><td colspan=6 align=right><div style="font-size: 10px;color: #dadada;" id="dumdiv">

<a href="https://freesitetool.blogspot.com/" id="dum" style="text-decoration:none;color: #dadada;"></a></div></td></tr>

</table>

</form>


 



How To Use These Code ?

Just copy these above following code and paste in your blogger or wordpress website post in HTML view.


S.NO All SEO And Other Tools Name Download Buttons Demo Buttons
1. Instagram Hashtag Finder Tool
2. Fancy Text Generator Tool
3. Logo & Favicon Maker Tool
4. iFrame Generator Tool
5. Age Calculator Tool
6. Hex Color Picker Tool
7. Youtube Video Downloader Tool
8. Meta Tag Generator Tool
9. QR Code Maker Tool
10. Privacy & Policy Generator Tool
11. Terms & Conditions Generator Tool
12. About Us Page Generator Tool
13. Youtube Thumbnail Downloader Tool
14. HTML To XML Converter Tool
15. Gradient Color Code Picker Tool

Click Here To Get More Tools