oct_to_dec
Converts a string of octal digits to a decimal value.
dec = oct_to_dec("173"); // dec == 123
dec = oct_to_dec("710"); // dec == 456
dec = oct_to_dec("1425"); // dec == 789
- oct_to_dec(oct)
- Returns a decimal integer (real) representing the given octal string.
COPY/// oct_to_dec(oct)
//
// Returns a decimal integer (real)
// representing the given octal string.
//
// oct octal digits, string
//
/// GMLscripts.com/license
{
var oct, dec, o, p;
oct = argument0;
dec = 0;
o = "01234567";
for (p=1; p<=string_length(oct); p+=1) {
dec = dec << 3 | (string_pos(string_char_at(oct, p), o) - 1);
}
return dec;
}
Contributors: xot
GitHub: View · Commits · Blame · Raw