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

Invert GMLscripts.com

dec_to_oct

Converts a decimal value to a string of octal digits.

oct = dec_to_oct(123);  //  oct == "173"
oct = dec_to_oct(456);  //  oct == "710"
oct = dec_to_oct(789);  //  oct == "1425"
dec_to_oct(dec)
Returns a string of octal digital (3 bits each) representing the given decimal integer.
COPY/// dec_to_oct(dec)
//
//  Returns a string of octal digital (3 bits each)
//  representing the given decimal integer.
//
//      dec         non-negative integer, real
//
/// GMLscripts.com/license
{
    var dec, oct, o;
    dec = argument0
    oct = "";
    o = "01234567";
    do {
        oct = string_char_at(o, (dec & 7) + 1) + oct;
        dec = dec >> 3;
    } until (dec == 0);
    return oct;
}

Contributors: xot

GitHub: View · Commits · Blame · Raw