Advertisement
C_Volume2 Calculators & Science #80943

Hex & Decimal Conversion

Convert numbers from Hex to Decimal and from Decimal to Hex.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<html>
<head>
<title>Hex & Decimal Conversion</title>
<script language="javascript">
<!--
function Hex2Dec(HexVal) {
	var HexVal = HexVal.toUpperCase();
	return parseInt(HexVal,16);
}
function Dec2Hex(DecVal) {
	var HexChars = '0123456789ABCDEF';
	var HexStr = ''
	while (DecVal>0){
		var HexStr = HexChars.charAt( DecVal%16 ) + HexStr;
		var DecVal = Math.floor(DecVal/16);
	}
	return HexStr
}
//--> 
</script>
</head>
<body bgcolor="#ffffff">

<form name="ConvertIt">
	<table cellpadding="2" cellspacing="0" border="0">
	<tr>
		<td>Decimal Value</td>
		<td><input type="text" name="DecValue" size="10"></td>
		<td><input type="button" value="Convert to HEX" onclick="alert( Dec2Hex(document.ConvertIt.DecValue.value) )"></td>
	</tr>
	<tr>
		<td colspan="3">&nbsp;</td>
	</tr>
	<tr>
		<td>HEX Value</td>
		<td><input type="text" name="HexValue" size="10"></td>
		<td><input type="button" value="Convert to Decimal" onclick="alert( Hex2Dec(document.ConvertIt.HexValue.value) )"></td>
	</tr>
	</table>
</form>

</body>
</html>
Original Comments (3)
Recovered from Wayback Machine