| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 956 人关注过本帖
标题:test,dont enter
只看楼主 加入收藏
海蓝啸
Rank: 5Rank: 5
来 自:安徽
等 级:贵宾
威 望:17
帖 子:1611
专家分:0
注 册:2006-4-3
收藏
得分:0 
科学计数器
程序代码:
<script language=\"javascript\">
r=new Array(2); function initialize(){ currOper=\"start\"; r[0]=\"0\"; r[1]=\"0\"; operand=\"\"; ix=0; } function addDigit(n){ if(currOper==\"Int\" || currOper==\"Float\") r[ix]=appendDigit(r[ix],n) else{ r[ix]=\"\"+n; currOper=\"Int\"; } showinForm(r[ix]); } function appendDigit(n1,n2){ if(n1==\"0\") return \"\"+n2; var s=\"\"; s+=n1; s+=n2; return s; } function showinForm(s){ document.calculator.total.value=s; } function addDecimalPoint(){ if(currOper!=\"Float\"){ decimal=true; r[ix]+=\".\"; if(currOper==\"Operator\" || currOper==\"getoperand\") r[ix]=\"0.\" currOper=\"Float\"; showinForm(r[ix]); } } function clearDisplay(){ initialize(); showinForm(r[0]); } function changeSign(){ if(r[ix].charAt(0)==\"-\") r[ix]=r[ix].substring(1,r[ix].length); else if(parseFloat(r[ix])!=0) r[ix]=\"-\"+r[ix]; showinForm(r[ix]); } function setTo(n){ r[ix]=\"\"+n; currOper=\"Operator\"; decimal=false; showinForm(r[ix]); } function Count(){ if(currOper==\"Int\" || currOper==\"Float\" || currOper==\"Operator\"){ if(ix==1){ r[0]=doCounting(operand,r[0],r[1]); ix=0; } } else if(currOper==\"getoperand2\"){ r[0]=doCounting(operand,r[1],r[0]); ix=0; } currOper=\"Operator\"; decimal==false; showinForm(r[ix]); } function doCounting(op,x,y){ var result=\"\"; switch(op){ case \"+\":result=\"\"+(parseFloat(x)+parseFloat(y));break; case \"-\":result=\"\"+(parseFloat(x)-parseFloat(y));break; case \"*\":result=\"\"+(parseFloat(x)*parseFloat(y));break; case \"/\":if(parseFloat(y)==0){ alert(\"分子为0,错误!\"); result=0; } else result=\"\"+(parseFloat(x)/parseFloat(y)); break; } return result; } function performOp(op){ if(currOper==\"start\"){ ++ix; operand=op; } else if(currOper==\"Int\" || currOper==\"Float\" || currOper==\"Operator\"){ if(ix==0){ ++ix; operand=op; } else{ r[0]=doCounting(operand,r[0],r[1]); showinForm(r[0]); operand=op; } } currOper=\"getoperand2\"; decimal=false; } function doFunction(){ var selectionList=document.calculator.functions; var selIX=selectionList.selectedIndex; var sel=selectionList.options[selIX].value; switch(sel){ case\"abs\":r[ix]=Math.abs(r[ix]);break; case\"acos\":r[ix]=Math.acos(r[ix]);break; case\"asin\":r[ix]=Math.asin(r[ix]);break; case\"atan\":r[ix]=Math.atan(r[ix]);break; case\"ceil\":r[ix]=Math.ceil(r[ix]);break; case\"cos\":r[ix]=Math.cos(r[ix]);break; case\"exp\":r[ix]=Math.exp(r[ix]);break; case\"floor\":r[ix]=Math.floor(r[ix]);break; case\"log\":r[ix]=Math.log(r[ix]);break; case\"sin\":r[ix]=Math.sin(r[ix]);break; case\"sqrt\":r[ix]=Math.sqrt(r[ix]);break; case\"tan\":r[ix]=Math.tan(r[ix]);break; } decimal=false; showinForm(r[ix]); }
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028725 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved