Mojo function
bin
bin(num: SIMD[type, 1], /, *, prefix: StringSlice[StaticConstantOrigin] = StringSlice("0b")) -> String
Return the binary string representation an integral value.
print(bin(123))
print(bin(-123))
print(bin(123))
print(bin(-123))
'0b1111011'
'-0b1111011'
'0b1111011'
'-0b1111011'
Args:
- num (
SIMD[type, 1]
): An integral scalar value. - prefix (
StringSlice[StaticConstantOrigin]
): The prefix of the formatted int.
Returns:
The binary string representation of num.
bin(b: SIMD[bool, 1], /, *, prefix: StringSlice[StaticConstantOrigin] = StringSlice("0b")) -> String
Returns the binary representation of a scalar bool.
Args:
- b (
SIMD[bool, 1]
): A scalar bool value. - prefix (
StringSlice[StaticConstantOrigin]
): The prefix of the formatted int.
Returns:
The binary string representation of b.
bin[T: Indexer, //](num: T, /, *, prefix: StringSlice[StaticConstantOrigin] = StringSlice("0b")) -> String
Returns the binary representation of an indexer type.
Parameters:
- T (
Indexer
): The Indexer type.
Args:
- num (
T
): An indexer value. - prefix (
StringSlice[StaticConstantOrigin]
): The prefix of the formatted int.
Returns:
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!