Mojo function
bin
bin(num: SIMD[type, 1], /, *, prefix: StringSlice[0, MutableStaticLifetime] = "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[0, MutableStaticLifetime]
): The prefix of the formatted int.
Returns:
The binary string representation of num.
bin(b: SIMD[bool, 1], /, *, prefix: StringSlice[0, MutableStaticLifetime] = "0b") -> String
Returns the binary representation of a scalar bool.
Args:
- βb (
SIMD[bool, 1]
): A scalar bool value. - βprefix (
StringSlice[0, MutableStaticLifetime]
): The prefix of the formatted int.
Returns:
The binary string representation of b.
bin[T: Indexer, //](num: T, /, *, prefix: StringSlice[0, MutableStaticLifetime] = "0b") -> String
Returns the binary representation of an indexer type.
Parameters:
- βT (
Indexer
): The Indexer type.
Args:
- βnum (
T
): An indexer value. - βprefix (
StringSlice[0, MutableStaticLifetime]
): 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!
π What went wrong?