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.

Try Oct in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions