Trait

BinaryInteger

An integer type with a binary representation.

Members

Functions

fun instance_bit_width() -> Int

Returns the number of bits in the representation of self.

fun signum() -> Int

Returns -1 if self is negative, 1 if it is positive, or 0 otherwise.

fun trailing_zeros() -> Int

Returns the number of bits equal to 0 on the right of the least significant bit equal to 1 in the representation of self.

fun quotient_and_remainder(dividing_by other: Self) -> (quotient: Self, remainder: Self)

Returns the quotient and remainder of dividing self by other.

fun words() -> CollectionOfOne<UInt>

Returns the words of in the representation of self, from the least to most significant.

fun /(_ other: Self) -> Self

Returns the quotient of dividing self by other.

fun /=(_ other: Self) { inout }

Writes the quotient of dividing self by other to self.

fun %(_ other: Self) -> Self

Returns the remainder of dividing self by other.

fun %=(_ other: Self) { inout }

Writes the remainder of dividing self by other to self.

fun <(_ other: Self) -> Bool

Returns true if self is smaller than other; returns false otherwise.

fun <=(_ other: Self) -> Bool

Returns true if self is smaller than or equal to other; returns false otherwise.

fun >(_ other: Self) -> Bool

Returns true if self is greater than other; returns false otherwise.

fun >=(_ other: Self) -> Bool

Returns true if self is greater than or equal to other; returns false otherwise.

fun &(_ other: Self) -> Self

Returns the bitwise AND of self and other.

fun &=(_ other: Self) { inout }

Writes the bitwise AND of self and other to self.

fun |(_ other: Self) -> Self

Returns the bitwise OR of self and other.

fun |=(_ other: Self) { inout }

Writes the bitwise OR of self and other to self.

fun ^(_ other: Self) -> Self

Returns the bitwise XOR of self and other.

fun ^=(_ other: Self) { inout }

Writes the bitwise XOR of self and other to self.

fun <<(_ n: Int) -> Self

Returns self with its binary representation shifted by n digits to the left.

fun <<=(_ n: Int) { inout }

Shifts the binary representation of self by n digits to the left.

fun >>(_ n: Int) -> Self

Returns self with its binary representation shifted by n digits to the right.

fun >>=(_ n: Int) { inout }

Shifts the binary representation of self by n digits to the right.

static fun is_signed() -> Bool

Returns true if this type is a signed integer.

Initializers

init()

Creates an instance with value 0.

init<T: BinaryInteger>(truncating_or_extending source: T)

Creates an instance with the bit representation of source, truncating or sign-extending it to fit the bit representation of Self.