oct

oct(value)

Try it yourself:

See also:

oct(): display an integer in octal

oct(x) represents an integer in base 8, using digits 0 through 7. Octal is compact for groups of three binary bits and remains useful in some permissions and legacy-system contexts.

Example

oct(64) produces an octal representation of 100 because 1×8² equals 64. The notation prefix identifies the base and avoids confusing an octal result with decimal text.

Related bases

Use bin() for base 2 and hex() for base 16. Inspect bit masks using bitAnd() or bitOr(). Use isInteger() to validate input.

Caveat

Supply integers. Fractional values require an intentional conversion rule and are not simply octal integers.

All functions