Skip to main content

U256

Struct U256 

Source
#[repr(C, align(32))]
pub struct U256(pub [u64; 4]);
Expand description

Entier 256-bit non signé représenté sur 4 mots de 64-bit (Little-Endian).

self.0[0] contient les bits 0..64, self.0[3] contient les bits 192..256.

Aligné sur 32 octets pour maximiser l’efficacité du cache et des registres AVX/SIMD du CPU.

Tuple Fields§

§0: [u64; 4]

Implementations§

Source§

impl U256

Source

pub const ZERO: Self

Constante Zéro.

Source

pub const ONE: Self

Constante Un.

Source

pub const fn from_limbs(limbs: [u64; 4]) -> Self

Création à partir de 4 mots u64 (Little-Endian : limbs[0] = bits de poids faible).

Source

pub fn wrapping_add(&self, rhs: &Self) -> Self

Addition 256-bit déterministe avec propagation de la retenue (Overflow).

Le résultat est tronqué mod 2²⁵⁶ (sémantique “wrapping” standard) : tout débordement au-delà du 4ème mot est silencieusement abandonné.

Utilise overflowing_add sous le capot pour une traduction directe en instructions ASM CPU (ADC).

Source

pub fn wrapping_mul(&self, rhs: &Self) -> Self

Multiplication 256-bit x 256-bit -> 256-bit (tronquée mod 2²⁵⁶).

Implémentation “schoolbook” (Comba), colonne par colonne, avec propagation complète de la retenue à chaque produit partiel. Zéro allocation, zéro mémoire heap, 100% dans les registres CPU.

Toute contribution qui dépasserait le bit 255 (c’est-à-dire les produits partiels a[i] * b[j] avec i + j >= 4, ainsi que la retenue finale de la dernière colonne) est abandonnée, conformément à la sémantique “wrapping” (résultat mod 2²⁵⁶).

Source

pub fn wrapping_sub(&self, rhs: &Self) -> Self

Soustraction 256-bit déterministe avec propagation de l’emprunt (Borrow).

Le résultat est tronqué mod 2²⁵⁶ : si rhs > self, le résultat “boucle” (comportement identique à u64::wrapping_sub).

Trait Implementations§

Source§

impl Clone for U256

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for U256

Source§

impl Debug for U256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for U256

Source§

impl PartialEq for U256

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for U256

Auto Trait Implementations§

§

impl Freeze for U256

§

impl RefUnwindSafe for U256

§

impl Send for U256

§

impl Sync for U256

§

impl Unpin for U256

§

impl UnsafeUnpin for U256

§

impl UnwindSafe for U256

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.