bin_to_hex

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

{
    var bin,hex,n,h,l,p;
    bin = argument0;
    hex = "";
    n = "0000101100111101000";
    h = "0125B6C937FEDA48";
    l = string_length(bin);
    bin = string_repeat("0",3-(l-1) mod 4)+bin;
    for (p=1; p<=l; p+=4) {
        hex += string_char_at(h,string_pos(string_copy(bin,p,4),n));
    }
    return hex;
}

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


comments powered by Disqus