High School Math

MISSION STATEMENT: To encourage and promote a greater use of the internet and computer technology in the math classroom. For educators, students, parents and homeschoolers.

Friday, May 11, 2007

Decimal to New Base

To Convert any Decimal number into any other base number.
1) Copy & Paste the code between the dotted lines into Notepad.
2) Save the program onto your computer as DecToBase.html.
3) Left Click on DecToBase.html to run the program.
4) Input your decimal number and your new base to convert into.
5) Click the equal sign button and see your answer.
.............................
<HTML><HEAD>
<SCRIPT LANGUAGE="JavaScript">
function toBin(form) {
base = parseInt(form.base.value);
num = parseInt(form.num.value);
form.amount.value = num.toString(base);}
</script></HEAD><BODY>
<form name=numform><center>Convert Decimal
<input type=text name=num size=4> to base
<input type=text name=base size=4 value=2
onBlur="if ((this.value<1)||(this.value>36)){
alert('The base must be between 2 and 36.');
this.select();this.focus();}">
<input type=button value=" = "
onclick="toBin(this.form)">
<input type=text name=amount size=12>
</center></form></BODY></HTML>
........................................
More Math Stuff at www.TheMathWebSite.com.