吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1769|回复: 2
收起左侧

[其他转载] 双浮点计算源码

  [复制链接]
lllkkk8 发表于 2020-9-29 05:29
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>双字换算计算机</title>
</head>
<body>
<h1>双浮点运算计算器</h1>
初始数值:<input id="input" type="text" value="1" /><br><br>
双字数值:<input id="result" type="text" value="1072693248" /><br><br>
<input id="calculate" type="button" value="开始计算"/>
</body>
<script>
var button = window.document.getElementById("calculate");
var result = window.document.getElementById("result");
button.onclick = gogogo;
function checkNum(){ //输入审查
var vnum1 = window.document.getElementById("input").value;
return isNaN(vnum1)?null:vnum1;
}
function cal(a){ //计算过程
if (a!=null){
return 1072693248 + Math.pow(2,(20-Math.floor(Math.log(a)/Math.log(2))))*(a- Math.pow(2,(Math.floor(Math.log(a)/Math.log(2)))))+ Math.pow(2,20) * Math.floor(Math.log(a)/Math.log(2));
}
}
function coutRes(b){ //输出结果
if (b != null){
result.value = b;
}else{
result.value = "数值不正确。";
}
}
function gogogo(){ //清除上一次残留
result.value = "";
coutRes(cal(checkNum()));
}
</script>
</html>


保存htm 使用

免费评分

参与人数 3吾爱币 +2 热心值 +3 收起 理由
tyh0730 + 1 我很赞同!
yang1825 + 1 + 1 谢谢分享
joneqm + 1 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

feng645806 发表于 2020-9-29 06:15
不错的代码分享
lovxyj 发表于 2020-9-29 07:42
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-4 12:10

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表