dec_to_bin

Downloaddec_to_bin(dec)   Returns a string of binary digits converted from the given non-negative integer.
/*
**  Usage:
**      dec_to_bin(dec)
**
**  Arguments:
**      dec     a non-negative integer
**
**  Returns:
**      a string of binary digits, one bit per character
**
**  GMLscripts.com
*/

{
    var dec,bin;
    dec = argument0;
    if (dec) bin = "" else bin="0";
    while (dec) {
        bin = string_char_at("01",(dec & 1) + 1) + bin;
        dec = dec >> 1;
    }
    return bin;
}

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


comments powered by Disqus