[][src]Struct bee_crypto::ternary::bigint::i384::I384

pub struct I384<E, T> { /* fields omitted */ }

A big integer encoding a signed integer with 384 bits.

T is usually taken as a [u32; 12] or [u8; 48].

E refers to the endianness of the digits in T. This means that in the case of [u32; 12], if E == BigEndian, that the u32 at position i=0 is considered the most significant digit. The endianness E here makes no statement about the endianness of each single digit within itself (this is then dependent on the endianness of the platform this code is run on).

For E == LittleEndian the digit at the last position is considered to be the most significant.

Implementations

impl I384<BigEndian, U8Repr>[src]

pub const fn from_array(inner: U8Repr) -> Self[src]

Creates an instance from an array of inner representation.

impl I384<BigEndian, U32Repr>[src]

pub const fn from_array(inner: U32Repr) -> Self[src]

Creates an instance from an array of inner representation.

impl I384<LittleEndian, U8Repr>[src]

pub const fn from_array(inner: U8Repr) -> Self[src]

Creates an instance from an array of inner representation.

impl I384<LittleEndian, U32Repr>[src]

pub const fn from_array(inner: U32Repr) -> Self[src]

Creates an instance from an array of inner representation.

impl I384<BigEndian, U8Repr>[src]

pub const fn zero() -> Self[src]

Returns the appropriate constant value.

pub const fn one() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_one() -> Self[src]

Returns the appropriate constant value.

pub const fn two() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_two() -> Self[src]

Returns the appropriate constant value.

pub const fn max() -> Self[src]

Returns the appropriate constant value.

pub const fn min() -> Self[src]

Returns the appropriate constant value.

impl I384<LittleEndian, U8Repr>[src]

pub const fn zero() -> Self[src]

Returns the appropriate constant value.

pub const fn one() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_one() -> Self[src]

Returns the appropriate constant value.

pub const fn two() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_two() -> Self[src]

Returns the appropriate constant value.

pub const fn max() -> Self[src]

Returns the appropriate constant value.

pub const fn min() -> Self[src]

Returns the appropriate constant value.

impl I384<BigEndian, U32Repr>[src]

pub const fn zero() -> Self[src]

Returns the appropriate constant value.

pub const fn one() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_one() -> Self[src]

Returns the appropriate constant value.

pub const fn two() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_two() -> Self[src]

Returns the appropriate constant value.

pub const fn max() -> Self[src]

Returns the appropriate constant value.

pub const fn min() -> Self[src]

Returns the appropriate constant value.

impl I384<LittleEndian, U32Repr>[src]

pub const fn zero() -> Self[src]

Returns the appropriate constant value.

pub const fn one() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_one() -> Self[src]

Returns the appropriate constant value.

pub const fn two() -> Self[src]

Returns the appropriate constant value.

pub const fn neg_two() -> Self[src]

Returns the appropriate constant value.

pub const fn max() -> Self[src]

Returns the appropriate constant value.

pub const fn min() -> Self[src]

Returns the appropriate constant value.

impl I384<BigEndian, U8Repr>[src]

pub fn not_inplace(&mut self)[src]

Applies not to all bytes of the I384.

impl I384<BigEndian, U32Repr>[src]

pub fn add_inplace(&mut self, other: Self)[src]

Adds other onto self in place.

pub fn add_digit_inplace<T: Into<u32>>(&mut self, other: T) -> usize[src]

Adds other in place, returning the number of digits required to accomodate other (starting from the least significant one).

pub fn as_u384(self) -> U384<BigEndian, U32Repr>[src]

Reinterprets the I384 as an U384.

pub fn from_t242(value: T242<Btrit>) -> Self[src]

Creates an I384 from a balanced T242.

pub fn is_positive(&self) -> bool[src]

Checks if the I384 is positive.

pub fn is_negative(&self) -> bool[src]

Checks if the I384 is negative.

pub fn not_inplace(&mut self)[src]

Applies logical not to all elements in a &[u32], modfiying them in place.

Examples

This example is not tested
let xs: I384<LittleEndian, _> = I384::from_array([0xffff_ffffu32; LEN_IN_U32]);
let mut ys = I384::from_array([0x0000_0000u32; LEN_IN_U32]);
ys.not_inplace();
assert_eq!(xs, ys);

pub fn shift_into_u384(self) -> U384<BigEndian, U32Repr>[src]

Shifts the I384 into unsigned space.

pub fn sub_inplace(&mut self, other: Self)[src]

Subtract other from self inplace.

This function is defined in terms of overflowing_add by making use of the following identity (in terms of Two's complement, and where ! is logical bitwise negation):

!x = -x -1 => -x = !x + 1

TODO: Verifiy that the final assert is indeed not necessary. Preliminary testing shows that results are as expected.

pub fn sub_integer_inplace<T: Into<u32>>(&mut self, other: T) -> usize[src]

Subtracts other in place, returning the number of digits required to accomodate other (starting from the least significant one).

pub fn try_from_t243(balanced_trits: T243<Btrit>) -> Result<Self, Error>[src]

Creates an I384 from a balanced T243.

impl I384<LittleEndian, U32Repr>[src]

pub fn add_inplace(&mut self, other: Self)[src]

Adds other onto self in place.

pub fn add_digit_inplace<T: Into<u32>>(&mut self, other: T) -> usize[src]

Adds other in place, returning the number of digits required to accomodate other (starting from the least significant one).

pub fn as_u384(self) -> U384<LittleEndian, U32Repr>[src]

Reinterprets the I384 as an U384.

pub fn from_t242(value: T242<Btrit>) -> Self[src]

Creates an I384 from a balanced T242.

pub fn is_positive(&self) -> bool[src]

Checks if the I384 is positive.

pub fn is_negative(&self) -> bool[src]

Checks if the I384 is negative.

pub fn not_inplace(&mut self)[src]

Applies logical not to all elements in a &[u32], modfiying them in place.

Examples

This example is not tested
let xs: I384<LittleEndian, _> = I384::from_array([0xffff_ffffu32; LEN_IN_U32]);
let mut ys = I384::from_array([0x0000_0000u32; LEN_IN_U32]);
ys.not_inplace();
assert_eq!(xs, ys);

pub fn shift_into_u384(self) -> U384<LittleEndian, U32Repr>[src]

Shifts the I384 into unsigned space.

pub fn sub_inplace(&mut self, other: Self)[src]

Subtract other from self inplace.

This function is defined in terms of overflowing_add by making use of the following identity (in terms of Two's complement, and where ! is logical bitwise negation):

!x = -x -1 => -x = !x + 1

TODO: Verifiy that the final assert is indeed not necessary. Preliminary testing shows that results are as expected.

pub fn sub_integer_inplace<T: Into<u32>>(&mut self, other: T) -> usize[src]

Subtracts other in place, returning the number of digits required to accomodate other (starting from the least significant one).

pub fn try_from_t243(balanced_trits: T243<Btrit>) -> Result<Self, Error>[src]

Tries to create an I384 from a balanced T243.

pub fn zero_most_significant_trit(&mut self)[src]

Zeroes the most significant trit of the I384.

Trait Implementations

impl<E: Clone, T: Clone> Clone for I384<E, T>[src]

impl<E: Copy, T: Copy> Copy for I384<E, T>[src]

impl<E, T, D> Debug for I384<E, T> where
    E: Debug,
    T: BinaryRepresentation<Inner = D>,
    D: Debug
[src]

impl Default for I384<BigEndian, U8Repr>[src]

impl Default for I384<BigEndian, U32Repr>[src]

impl Default for I384<LittleEndian, U8Repr>[src]

impl Default for I384<LittleEndian, U32Repr>[src]

impl<E, T> Deref for I384<E, T>[src]

type Target = T

The resulting type after dereferencing.

impl<E, T> DerefMut for I384<E, T>[src]

impl Eq for I384<BigEndian, U8Repr>[src]

impl Eq for I384<BigEndian, U32Repr>[src]

impl Eq for I384<LittleEndian, U8Repr>[src]

impl Eq for I384<LittleEndian, U32Repr>[src]

impl From<I384<BigEndian, [u32; 12]>> for I384<BigEndian, U8Repr>[src]

impl From<I384<BigEndian, [u32; 12]>> for I384<LittleEndian, U32Repr>[src]

impl From<I384<BigEndian, [u32; 12]>> for T243<Btrit>[src]

impl From<I384<BigEndian, [u8; 48]>> for I384<BigEndian, U32Repr>[src]

impl From<I384<BigEndian, [u8; 48]>> for I384<LittleEndian, U8Repr>[src]

impl From<I384<BigEndian, [u8; 48]>> for T243<Btrit>[src]

impl From<I384<LittleEndian, [u32; 12]>> for I384<LittleEndian, U8Repr>[src]

impl From<I384<LittleEndian, [u32; 12]>> for I384<BigEndian, U32Repr>[src]

impl From<I384<LittleEndian, [u32; 12]>> for T243<Btrit>[src]

impl From<I384<LittleEndian, [u8; 48]>> for I384<LittleEndian, U32Repr>[src]

impl From<I384<LittleEndian, [u8; 48]>> for I384<BigEndian, U8Repr>[src]

impl From<T242<Btrit>> for I384<BigEndian, U8Repr>[src]

impl From<T242<Btrit>> for I384<BigEndian, U32Repr>[src]

impl From<T242<Btrit>> for I384<LittleEndian, U32Repr>[src]

impl Ord for I384<BigEndian, U8Repr>[src]

impl Ord for I384<BigEndian, U32Repr>[src]

impl Ord for I384<LittleEndian, U8Repr>[src]

impl Ord for I384<LittleEndian, U32Repr>[src]

impl PartialEq<I384<BigEndian, [u32; 12]>> for I384<BigEndian, U32Repr>[src]

impl PartialEq<I384<BigEndian, [u8; 48]>> for I384<BigEndian, U8Repr>[src]

impl PartialEq<I384<LittleEndian, [u32; 12]>> for I384<LittleEndian, U32Repr>[src]

impl PartialEq<I384<LittleEndian, [u8; 48]>> for I384<LittleEndian, U8Repr>[src]

impl PartialOrd<I384<BigEndian, [u32; 12]>> for I384<BigEndian, U32Repr>[src]

impl PartialOrd<I384<BigEndian, [u8; 48]>> for I384<BigEndian, U8Repr>[src]

impl PartialOrd<I384<LittleEndian, [u32; 12]>> for I384<LittleEndian, U32Repr>[src]

impl PartialOrd<I384<LittleEndian, [u8; 48]>> for I384<LittleEndian, U8Repr>[src]

impl TryFrom<I384<BigEndian, [u32; 12]>> for T242<Btrit>[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<I384<BigEndian, [u8; 48]>> for T242<Btrit>[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<I384<LittleEndian, [u32; 12]>> for T242<Btrit>[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<I384<LittleEndian, [u8; 48]>> for T242<Btrit>[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<T243<Btrit>> for I384<BigEndian, U8Repr>[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<T243<Btrit>> for I384<BigEndian, U32Repr>[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<T243<Btrit>> for I384<LittleEndian, U32Repr>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<E, T> RefUnwindSafe for I384<E, T> where
    E: RefUnwindSafe,
    T: RefUnwindSafe

impl<E, T> Send for I384<E, T> where
    E: Send,
    T: Send

impl<E, T> Sync for I384<E, T> where
    E: Sync,
    T: Sync

impl<E, T> Unpin for I384<E, T> where
    E: Unpin,
    T: Unpin

impl<E, T> UnwindSafe for I384<E, T> where
    E: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> Sponge for U where
    T: Sponge,
    U: DerefMut<Target = T>, 
[src]

type Error = <T as Sponge>::Error

An error indicating that a failure has occured during a sponge operation.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.