<script language="JavaScript">
//Numbers converter script by Lars Peter Thomsen
//For this script and more Visit http://www.javascriptkit.com
//Please keep this notice intact
convertBase="0123456789abcdefghijklmnopqrstuvwxyz";
function convert(input,origin,dest) {
input=input.toString().toLowerCase(); origin=origin.toString(); dest=dest.toString()
var b=0; var Result="";
if (Number(origin)>convertBase.length || Number(dest)>convertBase.length || Number(origin)<2 || Number(dest)<2) return "Invalid numbering system"
for (var c=1;c<=input.length;c++) { b+=convertBase.indexOf(input.substring(c-1,c))*(Math.pow(origin,input.length-c)); if (convertBase.indexOf(input.substring(c-1,c)) > Number(origin)) return 'Character "'+input.substring(c-1,c)+'" not present in origin system'; }
var a=Math.floor(Math.log(b)/Math.log(dest))
while (a>-1) {
var e=Math.pow(dest,a)
a--;
var d=(b-b%e)/e+1;
b%=e;
Ciffer=convertBase.substring(d-1,d);
Result+=Ciffer;
}
return Result
}
</script>
<form>
<table><tr>
<td colspan="2"><b>Numbers converter</b><br><small>Converts numbers between different numbering scales<br>Please input the relevant information in the boxes</small></td>
</tr>
<tr height="1"><td colspan="2" bgcolor="black"></td></tr>
<tr>
<td>Number to convert:<br><small>May hold numbers as well as letters</small></td>
<td><input type="text" name="originalNumber"></td>
</tr>
<tr height="1"><td colspan="2" bgcolor="gray"></td></tr>
<tr>
<td>Scale to convert from:<br><small>Fx. 2 for binary or 16 for hexadecimal<br>min. 2, max. <script>document.write(convertBase.length)</script></small></td>
<td><input type="text" name="originalScale"></td>
</tr>
<tr height="1"><td colspan="2" bgcolor="gray"></td></tr>
<tr>
<td>Scale to convert to:</td>
<td><input type="text" name="destinationScale"></td>
</tr>
<tr height="1"><td colspan="2" bgcolor="gray"></td></tr>
<tr>
<td><input type="button" onClick='destinationNumber.value=convert(originalNumber.value,originalScale.value,destinationScale.value)' value="Convert"></td>
<td><input type="text" name="destinationNumber"></td>
</tr></table>
</form>
<p align="left"><font face="arial" size="-2">This free script provided by<br>
<a href="http://javascriptkit.com">JavaScript Kit</a></font></p>