For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
oct
def oct(value: Scalar, /, *, prefix: StaticString = "0o") -> String
Returns the octal string representation of an integer.
The string is prefixed with "0o" by default. Negative values start
with a minus sign, like -0o173.
For example:
print(oct(64)) # 0o100
print(oct(-123)) # -0o173
print(oct(64, prefix="")) # 100
Args:
- value (
Scalar): The integer value to format. - prefix (
StaticString): The prefix prepended to the digits (defaults to"0o").
Returns:
String: A string containing the octal representation of the value.
def oct[T: Intable, //](value: T, /, *, prefix: StaticString = "0o") -> String
Returns the octal string representation of a value.
The value is converted to Int and formatted in base 8, prefixed with
"0o" by default.
Parameters:
- T (
Intable): The type of the value. Must conform toIntable.
Args:
- value (
T): The value to format. - prefix (
StaticString): The prefix prepended to the digits (defaults to"0o").
Returns:
String: A string containing the octal representation of the value.
def oct(value: Scalar[DType.bool], /, *, prefix: StaticString = "0o") -> String
Returns the octal string representation of a bool value.
The bool is formatted as an integer, so the result is 0o0 or 0o1
with the default prefix.
Args:
- value (
Scalar[DType.bool]): The bool value to format. - prefix (
StaticString): The prefix prepended to the digits (defaults to"0o").
Returns:
String: A string containing the octal representation of the bool.