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

Invert gmlscripts.pro

dec_to_oct

Converts a decimal value to a string of octal digits.

  1. oct = dec_to_oct(123); // oct == "173"
  2. oct = dec_to_oct(456); // oct == "710"
  3. 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
  1. /// dec_to_oct(dec)
  2. //
  3. // Returns a string of octal digital (3 bits each)
  4. // representing the given decimal integer.
  5. //
  6. // dec non-negative integer, real
  7. //
  8. /// gmlscripts.pro/license
  9. {
  10. var dec, oct, o;
  11. dec = argument0
  12. oct = "";
  13. o = "01234567";
  14. do {
  15. oct = string_char_at(o, (dec & 7) + 1) + oct;
  16. dec = dec >> 3;
  17. } until (dec == 0);
  18. return oct;
  19. }

Contributors: xot

GitHub: View · Commits · Blame · Raw