Created
January 9, 2014 15:33
-
-
Save alemohamad/8335967 to your computer and use it in GitHub Desktop.
Convert integer to binary or hexadecimal, and the other way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dec2bin(number) { | |
return number.toString(2); | |
} | |
function bin2dec(number) { | |
return parseInt(number, 2); | |
} | |
function dec2hex(number) { | |
return number.toString(16); | |
} | |
function hex2dec(number) { | |
return parseInt(number,16); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment