Jump to content

toString() Help


DoyleChris98

Recommended Posts

I have a Number from a prompt stored as FREQ, now i want to convert it to HEX, For entry into another variable.

1200 (B10) = 4B0 (B16)

but if i put 1200 in as HEX (B16) that turns out 4608 in a converter on my phone.

I need to get to 4608.

 

not sure how to take 1200 and turn it into 4608.

Link to comment
Share on other sites

So you expect it to "magically" know whether you have entered decimal or hex? That is impossible.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>title</title><style></style><script>window.onerror = function(a, b, c, d){alert('Javascript Error:n'+a+'nURL: '+b+'nLine: '+c+'  Column: '+d);return true;}</script><script>'use strict';window.onload = init;function init() {document.getElementById('btn1').onclick = put;}function put(){var x = document.getElementById('in1').value;document.getElementById('outp').innerHTML = 'dec-to-hex = ' + Number(x).toString(16) +'<br/>hex-to-decimal = '+ parseInt(x, 16);}</script></head><body><input type="button" id="btn1" value="Enter"><input type="text" id="in1" value="1200"/><div id="outp"></div></body>    </html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...