hex_to_bin

Downloadhex_to_bin(hex)   Returns a string of binary digits converted from the given string of hexadecimal digits.
/*
**  Usage:
**      hex_to_bin(hex)
**
**  Arguments:
**      hex     a string of hexadeciaml digits, four bits per character
**
**  Returns:
**      a string of binary digits, one bit per character
**
**  GMLscripts.com
*/

{
    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;
}

Click if you've used this script[Please Login]
Projects: 6


comments powered by Disqus