You are currently viewing the GMLscripts.com static mirror. Forum access and script submissions are not available through this mirror.

Invert GMLscripts.com

hex_to_bin

Converts a string of hexidecimal digits to a string of binary digits.

bin = hex_to_bin("4");   // bin == "0100"
bin = hex_to_bin("15");  // bin == "00010101"
bin = hex_to_bin("1F");  // bin == "00011111"
hex_to_bin(hex)
Returns a string of binary digits (1 bit each) representing the given hexadecimal string.
COPY/// hex_to_bin(hex)
//
//  Returns a string of binary digits (1 bit each)
//  representing the given hexadecimal string.
//
//      hex         hexadecimal digits, string
//
/// GMLscripts.com/license
{
    var hex, bin, n, h, l, p;
    hex = string_upper(argument0);
    bin = "";
    n = "0000101100111101000";
    h = "0125B6C937FEDA48";
    l = string_length(hex);
    for (p=1; p<=l; p+=1) {
        bin += string_copy(n, string_pos(string_char_at(hex, p), h), 4);
    }
    return bin;
}

Contributors: xot

GitHub: View · Commits · Blame · Raw