[−][src]Struct iota_ternary_preview::bigint::u384::U384
Methods
impl<E, T> U384<E, T>
[src]
impl U384<BigEndian, U32Repr>
[src]
pub fn as_i384(self) -> I384<BigEndian, U32Repr>
[src]
pub fn shift_into_i384(self) -> 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 accomodate other
(starting
from the least significant one).
pub fn divide_by_two(&mut self)
[src]
Divides the u384 by 2 by bitshifting all bits one position to the right.
pub fn from_t242(trits: T242<Utrit>) -> Self
[src]
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
pub fn try_from_t243(trits: T243<Utrit>) -> Result<Self, Error>
[src]
Converts a signed integer represented by the balanced trits in t243
to the unsigned
binary integer u384
. It does this by shifting the t243
into signed range (by adding 1
to all its trits). t243
is assumed to be in little endian representation, with the most
significant trit being at the largest index in the array.
This is done in the following steps:
1
is added to all balanced trits, making them unsigned:{-1, 0, 1} -> {0, 1, 2}
.- The
t243
are converted to base 10 and through this immediately toi384
by calculating the sum `s
s = t_242 * 3^241 + t_241 * 3^240 + ... + t_{i+1} * 3^{i} + t_i * 3^{i-1} + t_{i-1} * 3^{i-2} + ... + t_1 * 3 + t_0
To perform this sum efficiently, its accumulation is staggered, so that each multiplication by 3 is done in each iteration of accumulating loop. This can be understood by factoring the powers of 3 from the previous sum:
s = (...((t_242 * 3 + t_241) * 3 + t_240) * 3 + ... + ...((t_{i+1} * 3 + t_i) * 3 + t_{i-1}) * 3 + ... + ...t_1) * 3 + t_0
Expressed in procedural form, this is the sum accumulated in acc
with the index i
running from [242..0
]:
acc = 0 for i, trit in trits.rev(): acc := acc + trit * 3^i
impl U384<LittleEndian, U32Repr>
[src]
pub fn as_i384(self) -> 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 accomodate other
(starting
from the least significant one).
pub fn divide_by_two(&mut self)
[src]
Divides the u384 by 2 by bitshifting all bits one position to the right.
pub fn from_t242(trits: T242<Utrit>) -> Self
[src]
pub fn shift_into_i384(self) -> I384<LittleEndian, U32Repr>
[src]
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
pub fn try_from_t243(trits: T243<Utrit>) -> Result<Self, Error>
[src]
Converts a signed integer represented by the balanced trits in t243
to the unsigned
binary integer u384
. It does this by shifting the t243
into signed range (by adding 1
to all its trits). t243
is assumed to be in little endian representation, with the most
significant trit being at the largest index in the array.
This is done in the following steps:
1
is added to all balanced trits, making them unsigned:{-1, 0, 1} -> {0, 1, 2}
.- The
t243
are converted to base 10 and through this immediately toi384
by calculating the sum `s
s = t_242 * 3^241 + t_241 * 3^240 + ... + t_{i+1} * 3^{i} + t_i * 3^{i-1} + t_{i-1} * 3^{i-2} + ... + t_1 * 3 + t_0
To perform this sum efficiently, its accumulation is staggered, so that each multiplication by 3 is done in each iteration of accumulating loop. This can be understood by factoring the powers of 3 from the previous sum:
s = (...((t_242 * 3 + t_241) * 3 + t_240) * 3 + ... + ...((t_{i+1} * 3 + t_i) * 3 + t_{i-1}) * 3 + ... + ...t_1) * 3 + t_0
Expressed in procedural form, this is the sum accumulated in acc
with the index i
running from [242..0
]:
acc = 0 for i, trit in trits.rev(): acc := acc + trit * 3^i
impl U384<BigEndian, U8Repr>
[src]
pub const fn from_array(inner: U8Repr) -> Self
[src]
impl U384<BigEndian, U32Repr>
[src]
pub const fn from_array(inner: U32Repr) -> Self
[src]
impl U384<LittleEndian, U8Repr>
[src]
pub const fn from_array(inner: U8Repr) -> Self
[src]
impl U384<LittleEndian, U32Repr>
[src]
pub const fn from_array(inner: U32Repr) -> Self
[src]
impl U384<BigEndian, U8Repr>
[src]
pub const fn zero() -> Self
[src]
pub const fn one() -> Self
[src]
pub const fn two() -> Self
[src]
pub const fn max() -> Self
[src]
impl U384<LittleEndian, U8Repr>
[src]
pub const fn zero() -> Self
[src]
pub const fn one() -> Self
[src]
pub const fn two() -> Self
[src]
pub const fn max() -> Self
[src]
impl U384<BigEndian, U32Repr>
[src]
pub const fn zero() -> Self
[src]
pub const fn one() -> Self
[src]
pub const fn two() -> Self
[src]
pub const fn max() -> Self
[src]
impl U384<LittleEndian, U32Repr>
[src]
pub const fn zero() -> Self
[src]
pub const fn one() -> Self
[src]
pub const fn two() -> Self
[src]
pub const fn max() -> Self
[src]
Trait Implementations
impl<E: Clone, T: Clone> Clone for U384<E, T>
[src]
impl<E: Copy, T: Copy> Copy for U384<E, T>
[src]
impl<E: Debug, R: BinaryRepresentation, D> Debug for U384<E, R> where
E: Debug,
R: BinaryRepresentation<T = D>,
D: Debug,
[src]
E: Debug,
R: BinaryRepresentation<T = D>,
D: Debug,
impl Eq for U384<LittleEndian, U32Repr>
[src]
impl From<T242<Utrit>> for U384<LittleEndian, U32Repr>
[src]
impl From<U384<BigEndian, [u32; 12]>> for T243<Utrit>
[src]
impl From<U384<BigEndian, [u32; 12]>> for U384<BigEndian, U8Repr>
[src]
impl From<U384<BigEndian, [u32; 12]>> for U384<LittleEndian, U32Repr>
[src]
impl From<U384<BigEndian, [u8; 48]>> for U384<LittleEndian, U8Repr>
[src]
impl From<U384<LittleEndian, [u32; 12]>> for T242<Utrit>
[src]
fn from(binary_value: U384<LittleEndian, U32Repr>) -> Self
[src]
impl From<U384<LittleEndian, [u32; 12]>> for T243<Utrit>
[src]
fn from(value: U384<LittleEndian, U32Repr>) -> Self
[src]
impl From<U384<LittleEndian, [u32; 12]>> for U384<BigEndian, U32Repr>
[src]
fn from(value: U384<LittleEndian, U32Repr>) -> Self
[src]
impl From<U384<LittleEndian, [u8; 48]>> for U384<LittleEndian, U32Repr>
[src]
fn from(value: U384<LittleEndian, U8Repr>) -> Self
[src]
impl From<U384<LittleEndian, [u8; 48]>> for U384<BigEndian, U8Repr>
[src]
fn from(value: U384<LittleEndian, U8Repr>) -> Self
[src]
impl Ord for U384<LittleEndian, U32Repr>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<U384<LittleEndian, [u32; 12]>> for U384<LittleEndian, U32Repr>
[src]
impl PartialOrd<U384<LittleEndian, [u32; 12]>> for U384<LittleEndian, U32Repr>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl TryFrom<T243<Utrit>> for U384<LittleEndian, U32Repr>
[src]
Auto Trait Implementations
impl<E, T> RefUnwindSafe for U384<E, T> where
E: RefUnwindSafe,
T: RefUnwindSafe,
E: RefUnwindSafe,
T: RefUnwindSafe,
impl<E, T> Send for U384<E, T> where
E: Send,
T: Send,
E: Send,
T: Send,
impl<E, T> Sync for U384<E, T> where
E: Sync,
T: Sync,
E: Sync,
T: Sync,
impl<E, T> Unpin for U384<E, T> where
E: Unpin,
T: Unpin,
E: Unpin,
T: Unpin,
impl<E, T> UnwindSafe for U384<E, T> where
E: UnwindSafe,
T: UnwindSafe,
E: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,