Link to home
Start Free TrialLog in
Avatar of wantime
wantime

asked on

Javascript: Decimal to Hex Problem

Hello all,

i would like to convert Decimal to Hex.

the problem i met is:

wenn i tried to convert decimal 987654321 to Hex, i get the value 7267464261. What i really wanted are 3AD168B1.

following are codes.

anyone knows where is the problem?

thanks,
wantime
<html>
<body>


<p id="demo"></p>

<script type="text/javascript">
function DecToHex(d) {return d.toString(8)}
window.onload=function() {
    var dx = DecToHex(987654321);
    document.getElementById("demo").innerHTML= dx;
}

</script>

</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Proculopsis
Proculopsis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial