docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

core::num::impl i16

本頁內容

API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。

impl i16

  • pub const MIN: i16 = -32767 - 1§

    Source

    The smallest value.

  • pub const MAX: i16 = 32767§

    Source

    The largest value.

  • pub const BITS: u32 = 16§

    Source

    The width in bits.

  • pub const fn wrapping_add(self, rhs: i16) -> i16§

    Source

    self + rhs, wrapping around at the bounds.

  • pub const fn wrapping_sub(self, rhs: i16) -> i16§

    Source

    self - rhs, wrapping around at the bounds.

  • pub const fn wrapping_mul(self, rhs: i16) -> i16§

    Source

    self * rhs, wrapping around at the bounds.

  • pub const fn count_ones(self) -> u32§

    Source

    The number of one bits.

  • pub const fn count_zeros(self) -> u32§

    Source

    The number of zero bits.

  • pub const fn leading_zeros(self) -> u32§

    Source

    The number of zero bits above the highest one bit.

  • pub const fn trailing_zeros(self) -> u32§

    Source

    The number of zero bits below the lowest one bit.

  • pub const fn leading_ones(self) -> u32§

    Source

    The number of one bits above the highest zero bit.

  • pub const fn trailing_ones(self) -> u32§

    Source

    The number of one bits below the lowest zero bit.

  • pub const fn rotate_left(self, n: u32) -> i16§

    Source

    The bits shifted left by n, those shifted out coming back on the right.

  • pub const fn rotate_right(self, n: u32) -> i16§

    Source

    The bits shifted right by n, those shifted out coming back on the left.

  • pub const fn swap_bytes(self) -> i16§

    Source

    The bytes in reverse order.

  • pub const fn to_be(self) -> i16§

    Source

    self in big-endian byte order (unchanged on a big-endian target).

  • pub const fn to_le(self) -> i16§

    Source

    self in little-endian byte order (unchanged on a little-endian target).

  • pub const fn from_be(x: i16) -> i16§

    Source

    The number whose big-endian bytes are x.

  • pub const fn from_le(x: i16) -> i16§

    Source

    The number whose little-endian bytes are x.

  • pub const fn to_le_bytes(self) -> [u8; 2]§

    Source

    The bytes, least significant first.

  • pub const fn to_be_bytes(self) -> [u8; 2]§

    Source

    The bytes, most significant first.

  • pub const fn to_ne_bytes(self) -> [u8; 2]§

    Source

    The bytes in the target's byte order.

  • pub const fn from_le_bytes(bytes: [u8; 2]) -> i16§

    Source

    The number of bytes, least significant first.

  • pub const fn from_be_bytes(bytes: [u8; 2]) -> i16§

    Source

    The number of bytes, most significant first.

  • pub const fn from_ne_bytes(bytes: [u8; 2]) -> i16§

    Source

    The number of bytes, in the target's byte order.

  • pub const fn checked_add(self, rhs: i16) -> i16 | none§

    Source

    self + rhs, or none on overflow.

  • pub const fn checked_sub(self, rhs: i16) -> i16 | none§

    Source

    self - rhs, or none on overflow.

  • pub const fn checked_mul(self, rhs: i16) -> i16 | none§

    Source

    self * rhs, or none on overflow.

  • pub const fn checked_div(self, rhs: i16) -> i16 | none§

    Source

    self / rhs, or none when rhs is 0 or the quotient overflows (MIN / -1).

  • pub const fn checked_rem(self, rhs: i16) -> i16 | none§

    Source

    self % rhs, or none when rhs is 0 or the division overflows (MIN % -1).

  • pub const fn checked_neg(self) -> i16 | none§

    Source

    -self, or none for MIN.

  • pub const fn checked_shl(self, n: u32) -> i16 | none§

    Source

    self << n, or none when n is at least BITS.

  • pub const fn checked_shr(self, n: u32) -> i16 | none§

    Source

    self >> n, or none when n is at least BITS.

  • pub const fn checked_pow(self, exp: u32) -> i16 | none§

    Source

    self to the exp, or none on overflow.

  • pub const fn wrapping_div(self, rhs: i16) -> i16§

    Source

    self / rhs; MIN / -1 wraps to MIN. Panics when rhs is 0.

  • pub const fn wrapping_rem(self, rhs: i16) -> i16§

    Source

    self % rhs; MIN % -1 is 0. Panics when rhs is 0.

  • pub const fn wrapping_neg(self) -> i16§

    Source

    -self, wrapping around: MIN stays MIN.

  • pub const fn wrapping_shl(self, n: u32) -> i16§

    Source

    self << (n % BITS).

  • pub const fn wrapping_shr(self, n: u32) -> i16§

    Source

    self >> (n % BITS).

  • pub const fn wrapping_pow(self, exp: u32) -> i16§

    Source

    self to the exp, wrapping around at the bounds.

  • pub const fn saturating_add(self, rhs: i16) -> i16§

    Source

    self + rhs, clamped to MIN..=MAX.

  • pub const fn saturating_sub(self, rhs: i16) -> i16§

    Source

    self - rhs, clamped to MIN..=MAX.

  • pub const fn saturating_mul(self, rhs: i16) -> i16§

    Source

    self * rhs, clamped to MIN..=MAX.

  • pub const fn saturating_neg(self) -> i16§

    Source

    -self, clamped: MIN gives MAX.

  • pub const fn saturating_pow(self, exp: u32) -> i16§

    Source

    self to the exp, clamped to MIN..=MAX.

  • pub const fn overflowing_add(self, rhs: i16) -> (i16, bool)§

    Source

    self + rhs wrapped, and whether it overflowed.

  • pub const fn overflowing_sub(self, rhs: i16) -> (i16, bool)§

    Source

    self - rhs wrapped, and whether it overflowed.

  • pub const fn overflowing_mul(self, rhs: i16) -> (i16, bool)§

    Source

    self * rhs wrapped, and whether it overflowed.

  • pub const fn overflowing_div(self, rhs: i16) -> (i16, bool)§

    Source

    self / rhs wrapped, and whether it overflowed (MIN / -1). Panics when rhs is 0.

  • pub const fn overflowing_rem(self, rhs: i16) -> (i16, bool)§

    Source

    self % rhs wrapped, and whether it overflowed (MIN % -1). Panics when rhs is 0.

  • pub const fn overflowing_neg(self) -> (i16, bool)§

    Source

    -self wrapped, and whether it overflowed (MIN).

  • pub const fn overflowing_shl(self, n: u32) -> (i16, bool)§

    Source

    self << (n % BITS), and whether n was at least BITS.

  • pub const fn overflowing_shr(self, n: u32) -> (i16, bool)§

    Source

    self >> (n % BITS), and whether n was at least BITS.

  • pub const fn overflowing_pow(self, exp: u32) -> (i16, bool)§

    Source

    self to the exp wrapped, and whether it overflowed.

  • pub const fn pow(self, exp: u32) -> i16§

    Source

    self to the exp; overflow is the arithmetic's (a panic; a wrap with overflow checks off).

  • pub const fn abs(self) -> i16§

    Source

    The absolute value; MIN.abs() overflows (panics; wraps with overflow checks off).

  • pub const fn checked_abs(self) -> i16 | none§

    Source

    The absolute value, or none for MIN.

  • pub const fn wrapping_abs(self) -> i16§

    Source

    The absolute value, wrapping around: MIN stays MIN.

  • pub const fn saturating_abs(self) -> i16§

    Source

    The absolute value, clamped: MIN gives MAX.

  • pub const fn unsigned_abs(self) -> u16§

    Source

    The absolute value as the unsigned type of the same width; never overflows.

  • pub const fn abs_diff(self, rhs: i16) -> u16§

    Source

    |self - rhs|, as the unsigned type of the same width; never overflows.

  • pub const fn signum(self) -> i16§

    Source

    -1, 0 or 1.

  • pub const fn is_positive(self) -> bool§

    Source

    true when self > 0.

  • pub const fn is_negative(self) -> bool§

    Source

    true when self < 0.

  • pub const fn div_floor(self, rhs: i16) -> i16§

    Source

    Quotient rounded toward negative infinity (Python's //); rem_floor is the matching remainder.

  • pub const fn rem_floor(self, rhs: i16) -> i16§

    Source

    The remainder with the divisor's sign (Python's %, Nabi's %%): self == self.div_floor(rhs) * rhs + self.rem_floor(rhs).

  • pub const fn div_euclid(self, rhs: i16) -> i16§

    Source

    Quotient rounded so that rem_euclid is never negative.

  • pub const fn rem_euclid(self, rhs: i16) -> i16§

    Source

    The remainder in 0..rhs.abs().

  • pub const fn isqrt(self) -> i16§

    Source

    Integer square root; panics on a negative number.

  • pub const fn checked_isqrt(self) -> i16 | none§

    Source

    The integer square root, or none for a negative number.

  • pub const fn ilog2(self) -> u32§

    Source

    floor(log2(self)); panics unless self > 0.

  • pub const fn ilog10(self) -> u32§

    Source

    floor(log10(self)); panics unless self > 0.

  • pub const fn ilog(self, base: i16) -> u32§

    Source

    floor(log(self, base)); panics unless self > 0 and base >= 2.

  • pub const fn checked_ilog2(self) -> u32 | none§

    Source

    floor(log2(self)), or none unless self > 0.

  • pub const fn checked_ilog10(self) -> u32 | none§

    Source

    floor(log10(self)), or none unless self > 0.

  • pub const fn checked_ilog(self, base: i16) -> u32 | none§

    Source

    floor(log(self, base)), or none unless self > 0 and base >= 2.