Module:DecToHex: Difference between revisions
From Australian Enthusiasts Wiki
Hex converter module |
Update to always zero-pad odd digit hexes |
||
| Line 6: | Line 6: | ||
hex = hex .. string.format("%x", decToConvert) | hex = hex .. string.format("%x", decToConvert) | ||
if ( | if (string.len(hex) % 2 == 1) then | ||
hex = "0" .. hex | hex = "0" .. hex | ||
end | end | ||
Latest revision as of 18:06, 4 March 2021
This Lua module converts a decimal input into a lowercase hex output.
To return a uppercase hex value, you must wrap the value in string.upper().