Last active
December 21, 2020 22:46
-
-
Save DragoniteSpam/699de4591ebd7d1715f9baa8f6b341e1 to your computer and use it in GitHub Desktop.
The opposite of hex().
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
function string_hex(value, padding) { | |
if (padding == undefined) padding = 0; | |
var s = sign(value); | |
var v = abs(value); | |
var output = ""; | |
while (v > 0) { | |
var c = v & 0xf; | |
output = chr(c + ((c < 10) ? 48 : 55)) + output; | |
v = v >> 4; | |
} | |
if (string_length(output) == 0) output = "0"; | |
return ((s < 0) ? "-" : "") + string_pad(output, "0", padding); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment