<b>Insert Decimal Number: </b><input type = "text" name = "deci" id = "deci" size = "15" maxlength = "15" />
<input type="button" value="Convert!" onclick="dec2bin()" />
<br><br>
<div id = "result"></div>
<script type = "text/javascript">
function dec2bin() {
var x = document.getElementById("deci").value;
if ((/[^0-9]/g.test(x)) || x == "") {
alert ("You must enter an integer decimal number!");
document.getElementById("deci").value = "";
document.getElementById("deci").focus();
return false;
}
x = parseInt(x);
var bin = x.toString(2);
var hex = x.toString(16).toUpperCase();
var octal = x.toString(8);
var figs = "The binary representation of " + x + " is " + bin + "<br>";
figs = figs + "The hexadecimal representation of " + x + " is " + hex + "<br>";
figs = figs + "The octal representation of " + x + " is " + octal + "<br>";
document.getElementById("result").innerHTML = figs;
}
</script>
<p align="center"><font face="arial" size="5">This free script provided by</font><br>
<font face="arial, helvetica" size="5"><a href="http://sourcecodester.com">Sourcecodester.com</a></font></p>
Number to Bin Converter Using Javascript.zip
需积分: 5 94 浏览量
2023-11-08
19:46:20
上传
评论
收藏 843B ZIP 举报
sanbaofengs
- 粉丝: 507
- 资源: 711
最新资源
- 基于matlab实现字符识别的参考程序,用所用的字体识别率挺高,部分手写的也能识别,但是还不能识别扭曲和倾斜的字符 .rar
- 基于matlab实现指纹识别系统 包括数据库导入、图像选择识别、帮助功能、识别图像可视、gabor滤波可视,实现界面操作.rar
- 基于matlab实现指纹识别,利用gabor滤波器,提取指纹特征,只能呢读取bmp图像.rar
- 基于matlab实现于数字图像相关方法中散斑质量评价
- 基于matlab实现遗传算法和佳点集遗传算法的基本思想和不同点,用遗传算法测试一标准函数 佳点集算法测试一标准函数
- tensorflow-gpu-2.5.1-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.0-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-gpu-2.5.2-cp39-cp39-manylinux2010-x86-64.whl
- 内含方正小标宋简体、仿宋-Gb2312、黑体、楷体、宋体,五个公文常用字体
- 记忆卡牌游戏源码及可运行文件
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈