Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @func dec_to_hex(dec [, digits])
- ///
- /// @desc Returns a string of hexadecimal digits.
- /// Hexadecimal strings are padded to an
- /// optional number of digits.
- ///
- /// @arg {real} dec non-negative integer
- /// @arg {real} digits minimum number of digits
- ///
- /// @return {string} hexadecimal
- ///
- /// GMLscripts.com/license
- {
- var dec = argument[0],
- dig = (argument_count > 1) ? argument[1] : 1,
- hex = "",
- h = "0123456789ABCDEF";
- while (dig-- || dec) {
- hex = string_char_at(h, (dec & $F) + 1) + hex;
- dec = dec >> 4;
- }
- return hex;
- }
Advertisement
Add Comment
Please, Sign In to add comment