JvavScript处理URL的GET数据 图片循环滚动代码

JvavScript二进制十进制转换

JvavScript二进制十进制转换
有从十进制转换的、有从二进制转换的、有从十六进制转换的,还有八进制的
大家如果需要的话可以拿去


<input type = "input" id="original" />
<input type = "button" onclick = change10() value = "从10进制转换" />
<input type = "button" onclick = change2() value = "从2进制转换" />
<input type = "button" onclick = change8() value = "从8进制转换" />
<input type = "button" onclick = change16() value = "从16进制转换" />
<script>
var oOriginal = document.getElementById("original");
function change10(){
var num = parseInt(oOriginal.value);
alert("2: " + num.toString(2) + "\n" + "8: " + num.toString(8) + "\n" + "10: " + num.toString(10) + "\n" + "16: " + num.toString(16));
}
function change2(){
var num = parseInt(oOriginal.value,2);
alert("2: " + num.toString(2) + "\n" + "8: " + num.toString(8) + "\n" + "10: " + num.toString(10) + "\n" + "16: " + num.toString(16));
}
function change8(){
var num = parseInt(oOriginal.value,8);
alert("2: " + num.toString(2) + "\n" + "8: " + num.toString(8) + "\n" + "10: " + num.toString(10) + "\n" + "16: " + num.toString(16));
}
function change16(){
var num = parseInt(oOriginal.value,16);
alert("2: " + num.toString(2) + "\n" + "8: " + num.toString(8) + "\n" + "10: " + num.toString(10) + "\n" + "16: " + num.toString(16));
}
</script>


如果是二进制,请输入如:1010
如果是16进制,请输入如:ff0000
即,不要加前缀
TAG: javascript教程 进制
kimi post in JavaScript教程 at 2007-11-08 21:37:57.
永久地址:http://ijavascript.cn/jiaocheng/javascript-change-294.html
在百度中搜索《JvavScript二进制十进制转换》。

发表评论

发表评论

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

网友评论仅供网友表达个人看法,并不表明本网同意其观点或证实其描述。