Created
February 10, 2010 00:30
-
-
Save itspriddle/299865 to your computer and use it in GitHub Desktop.
This file contains 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
# Convert dec => hex and hex => dec | |
def decimal_to_hex(number) | |
res = number.to_i.to_s(16) | |
res = "0" * (12 - res.length) << res if res.length < 12 | |
res | |
end | |
def hex_to_decimal(number) | |
"0x#{number}".hex | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment