pub struct i88(/* private fields */);Implementations§
Source§impl i88
impl i88
pub const BITS: u32 = $bit_count
pub const MIN: Self
pub const MAX: Self
Sourcepub const fn new(x: i128) -> Option<Self>
pub const fn new(x: i128) -> Option<Self>
Creates a i88 from a i128, returning None if the value does not fit in 88 bits.
This is the checked counterpart of new_unchecked and new_truncated. It is const, so it can be used to build constants; the type’s constant macro does exactly that and panics at compile time on failure.
§Examples
use nbyte_int::prelude::*;
assert_eq!(i88::new(0).map(|x| x.get()), Some(0));
assert_eq!(i88::new(i88::MAX.get()).map(|x| x.get()), Some(i88::MAX.get()));
// one past the maximum does not fit
assert!(i88::MAX.get().checked_add(1).and_then(i88::new).is_none());Sourcepub const unsafe fn new_unchecked(x: i128) -> Self
pub const unsafe fn new_unchecked(x: i128) -> Self
Sourcepub const unsafe fn from_bits(bits: i128) -> Self
pub const unsafe fn from_bits(bits: i128) -> Self
Creates a 11-byte integer from its exact raw bit pattern, bypassing all masking.
Unlike new_unchecked, which takes a logical integer value
and handles any necessary sign-bit masking, this transmutes the bits directly.
Only use it when you already have a pre-masked bit pattern matching the
type’s exact internal representation.
§Safety
Only the low 11 bytes of bits may be non-zero. The upper bytes must all be zero. Violating this is immediate undefined behavior (UB).
Sourcepub const fn new_truncated(bits: i128) -> Self
pub const fn new_truncated(bits: i128) -> Self
Creates a 11-byte integer by truncating the upper bits of the provided value.
This applies a bitmask to clear any bits outside the target bit-width.
This behaves identically to primitive narrowing casts (e.g., u32 as u16),
where values out of bounds wrap around.
Unlike new, this method will not return None on overflow.
Unlike new_unchecked or from_bits,
this method is always safe to call with any value because it strictly enforces
the memory layout invariants via masking.
Sourcepub const fn to_bits(self) -> i128
pub const fn to_bits(self) -> i128
Returns the raw bit pattern of the 11-byte integer as its underlying backing type.
This returns the exact memory representation of the integer where the upper padding bytes are guaranteed to be zero.
Warning on Signed Integers: This method does not perform sign extension.
If you call to_bits() on a negative value, the returned backing primitive
will have its upper bytes set to 0, which will change its logical value.
To retrieve the logical value with proper sign extension, always use get instead.
pub const fn swap_bytes(self) -> Self
pub const fn from_le(x: Self) -> Self
pub const fn from_be(x: Self) -> Self
pub const fn to_le(self) -> Self
pub const fn to_be(self) -> Self
pub const fn from_ne_bytes(bytes: [u8; 11]) -> Self
pub const fn from_le_bytes(bytes: [u8; 11]) -> Self
pub const fn from_be_bytes(bytes: [u8; 11]) -> Self
pub const fn to_ne_bytes(self) -> [u8; 11]
pub const fn to_le_bytes(self) -> [u8; 11]
pub const fn to_be_bytes(self) -> [u8; 11]
Sourcepub const fn get(self) -> i128
pub const fn get(self) -> i128
Returns the logical value of the 11-byte integer as its underlying i128 backing type.
For signed integers, this method performs proper sign extension. This ensures that negative values correctly retain their negative logical value when cast up to the wider backing primitive. For unsigned integers, the value is simply zero-extended.
If you need the raw, unextended memory layout (where the upper padding bytes
are strictly zeroed out regardless of sign), use to_bits instead.
Source§impl i88
impl i88
pub const fn from_str_radix( str: &str, radix: u32, ) -> Result<Self, ParseIntError>
Trait Implementations§
Source§impl AddAssign for i88
impl AddAssign for i88
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl AddAssign<&i88> for i88
impl AddAssign<&i88> for i88
Source§fn add_assign(&mut self, other: &i88)
fn add_assign(&mut self, other: &i88)
+= operation. Read moreimpl Copy for i88
Source§impl DivAssign for i88
impl DivAssign for i88
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl DivAssign<&i88> for i88
impl DivAssign<&i88> for i88
Source§fn div_assign(&mut self, other: &i88)
fn div_assign(&mut self, other: &i88)
/= operation. Read moreimpl Eq for i88
Source§impl MulAssign for i88
impl MulAssign for i88
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl MulAssign<&i88> for i88
impl MulAssign<&i88> for i88
Source§fn mul_assign(&mut self, other: &i88)
fn mul_assign(&mut self, other: &i88)
*= operation. Read moreSource§impl Ord for i88
impl Ord for i88
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for i88
impl PartialOrd for i88
Source§impl RemAssign for i88
impl RemAssign for i88
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moreSource§impl RemAssign<&i88> for i88
impl RemAssign<&i88> for i88
Source§fn rem_assign(&mut self, other: &i88)
fn rem_assign(&mut self, other: &i88)
%= operation. Read moreSource§impl SubAssign for i88
impl SubAssign for i88
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl SubAssign<&i88> for i88
impl SubAssign<&i88> for i88
Source§fn sub_assign(&mut self, other: &i88)
fn sub_assign(&mut self, other: &i88)
-= operation. Read more