Mojo function
bin
bin(num: Scalar[dtype], /, *, prefix: StringSlice[StaticConstantOrigin] = "0b") -> String
Return the binary string representation an integral value.
print(bin(123))
print(bin(-123))'0b1111011'
'-0b1111011'Args:
- num (
Scalar): An integral scalar value. - prefix (
StringSlice): The prefix of the formatted int.
Returns:
String: The binary string representation of num.
bin(b: Scalar[DType.bool], /, *, prefix: StringSlice[StaticConstantOrigin] = "0b") -> String
Returns the binary representation of a scalar bool.
Args:
- b (
Scalar): A scalar bool value. - prefix (
StringSlice): The prefix of the formatted int.
Returns:
String: The binary string representation of b.
bin[T: Intable, //](num: T, /, *, prefix: StringSlice[StaticConstantOrigin] = "0b") -> String
Returns the binary representation of an indexer type.
Parameters:
- T (
Intable): The Intable type.
Args:
- num (
T): An indexer value. - prefix (
StringSlice): The prefix of the formatted int.
Returns:
String: The binary string representation of num.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!