Skip to content

OCT$

Syntax

OCT$(X)

Versions: Extended, Disk

Description

Returns a string which represents the octal value of the decimal argument. X is rounded to an integer before OCT$(X) is evaluated.

The returned string contains only the digits 0-7, representing the octal (base-8) value of X.

Example

10 INPUT X
20 A$ = OCT$(X)
30 PRINT X; "DECIMAL IS "; A$; " OCTAL"
RUN
? 64
64 DECIMAL IS 100 OCTAL
Ok

10 PRINT OCT$(255)
RUN
377
Ok

See Also

  • ASC - Returns a numerical value that is the ASCII code of the first character of the string X$
  • CHR$ - Returns a one-character string whose ASCII code is the specified value
  • HEX$ - Returns a string which represents the hexadecimal value of the decimal argument
  • INSTR - Searches for the first occurrence of string Y$ in X$ and returns the position at which the match is found
  • LEFT$ - Return the leftmost N characters from a string
  • LEN - Returns the number of characters in X$
  • MID$ - Extract a substring from the middle of a string
  • MID$ Assignment - Replace characters within a string variable
  • RIGHT$ - Return the rightmost N characters from a string
  • SPACE$ - Returns a string of I spaces
  • SPC - Prints I blanks on the terminal
  • STR$ - Convert a number to its string representation
  • [STRING](string_dollar.md) - Returns a string of length I whose characters all have ASCII code J or the first character of X
  • VAL - Returns the numerical value of string X$