BigUInt

Struct BigUInt 

Source
pub struct BigUInt<T, const N: usize>
where T: TraitsBigUInt<T>,
{ /* private fields */ }
Expand description

big_uint.rs was too big because of documentation and plenty of examples So, in order to provide documentation without docs.rs’s failing generating documentation, dummy codes were made and documentation and examples were moved to big_uint_arithmetic.rs.

Trait Implementations§

Source§

impl<T, const N: usize> UpperExp for BigUInt<T, N>
where T: TraitsBigUInt<T>,

E formatting.

  • The UpperExp trait should format its output in scientific notation with a upper-case E.
  • For more information on the trait UpperExp, read more.
  • For more information on formatters, see the module-level documentation.
Source§

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

Formats the value using the given formatter.

§Arguments

f is a buffer, this method must write the formatted string into it, and is of the type &mut Formatter.

§Errors

This function should return Err if, and only if, the provided Formatter returns Err. String formatting is considered an infallible operation; this function only returns a Result because writing to the underlying stream might fail and it must provide a way to propagate the fact that an error has occurred back up the stack.

§Example 1
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:E}", a_biguint);
let txt = format!("{:E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 2
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:100E}", a_biguint);
let txt = format!("{:100E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76                   ");
§Example 3
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:0100E}", a_biguint);
let txt = format!("{:0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 4
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:20.9E}", a_biguint);
let txt = format!("{:20.9E}", a_biguint);
assert_eq!(txt, "1.234567890E76      ");
§Example 5
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:020.9E}", a_biguint);
let txt = format!("{:020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 6
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:21.13E}", a_biguint);
let txt = format!("{:21.13E}", a_biguint);
assert_eq!(txt, "1.2345678901235E76   ");
§Example 7
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:021.13E}", a_biguint);
let txt = format!("{:021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");
§Example 8
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<E}", a_biguint);
let txt = format!("{:<E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 9
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<100E}", a_biguint);
let txt = format!("{:<100E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76                   ");
§Example 10
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<0100E}", a_biguint);
let txt = format!("{:<0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 11
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<20.9E}", a_biguint);
let txt = format!("{:<20.9E}", a_biguint);
assert_eq!(txt, "1.234567890E76      ");
§Example 12
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<020.9E}", a_biguint);
let txt = format!("{:<020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 13
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<21.13E}", a_biguint);
let txt = format!("{:<21.13E}", a_biguint);
assert_eq!(txt, "1.2345678901235E76   ");
§Example 14
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:<021.13E}", a_biguint);
let txt = format!("{:<021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");
§Example 15
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:!<E}", a_biguint);
let txt = format!("{:<E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 16
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:@<100E}", a_biguint);
let txt = format!("{:@<100E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76@@@@@@@@@@@@@@@@@@@");
§Example 17
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:#<0100E}", a_biguint);
let txt = format!("{:#<0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 18
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:$<20.9E}", a_biguint);
let txt = format!("{:$<20.9E}", a_biguint);
assert_eq!(txt, "1.234567890E76$$$$$$");
§Example 19
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:%<020.9E}", a_biguint);
let txt = format!("{:%<020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 20
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^<21.13E}", a_biguint);
let txt = format!("{:^<21.13E}", a_biguint);
assert_eq!(txt, "1.2345678901235E76^^^");
§Example 21
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:&<021.13E}", a_biguint);
let txt = format!("{:&<021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");
§Example 22
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>E}", a_biguint);
let txt = format!("{:>E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 23
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>100E}", a_biguint);
let txt = format!("{:>100E}", a_biguint);
assert_eq!(txt, "                   1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 24
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>0100E}", a_biguint);
let txt = format!("{:>0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 25
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>20.9E}", a_biguint);
let txt = format!("{:>20.9E}", a_biguint);
assert_eq!(txt, "      1.234567890E76");
§Example 26
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>020.9E}", a_biguint);
let txt = format!("{:>020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 27
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>21.13E}", a_biguint);
let txt = format!("{:>21.13E}", a_biguint);
assert_eq!(txt, "   1.2345678901235E76");
§Example 28
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:>021.13E}", a_biguint);
let txt = format!("{:>021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");
§Example 29
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:!>E}", a_biguint);
let txt = format!("{:>E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 30
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:@>100E}", a_biguint);
let txt = format!("{:@>100E}", a_biguint);
assert_eq!(txt, "@@@@@@@@@@@@@@@@@@@1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 31
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:#>0100E}", a_biguint);
let txt = format!("{:#>0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 32
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:$>20.9E}", a_biguint);
let txt = format!("{:$>20.9E}", a_biguint);
assert_eq!(txt, "$$$$$$1.234567890E76");
§Example 33
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:%>020.9E}", a_biguint);
let txt = format!("{:%>020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 34
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^>21.13E}", a_biguint);
let txt = format!("{:^>21.13E}", a_biguint);
assert_eq!(txt, "^^^1.2345678901235E76");
§Example 35
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:&>021.13E}", a_biguint);
let txt = format!("{:&>021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");
§Example 36
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^E}", a_biguint);
let txt = format!("{:^E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 37
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^100E}", a_biguint);
let txt = format!("{:^100E}", a_biguint);
assert_eq!(txt, "         1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76          ");
§Example 38
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^0100E}", a_biguint);
let txt = format!("{:^0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 39
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^20.9E}", a_biguint);
let txt = format!("{:^20.9E}", a_biguint);
assert_eq!(txt, "   1.234567890E76   ");
§Example 40
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^020.9E}", a_biguint);
let txt = format!("{:^020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 41
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^21.13E}", a_biguint);
let txt = format!("{:^21.13E}", a_biguint);
assert_eq!(txt, " 1.2345678901235E76  ");
§Example 42
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^021.13E}", a_biguint);
let txt = format!("{:^021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");
§Example 43
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:!^E}", a_biguint);
let txt = format!("{:^E}", a_biguint);
assert_eq!(txt, "1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 44
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:@^100E}", a_biguint);
let txt = format!("{:@^100E}", a_biguint);
assert_eq!(txt, "@@@@@@@@@1.2345678901234567890123456789012345678901234567890123456789012345678901234567E76@@@@@@@@@@");
§Example 45
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:#^0100E}", a_biguint);
let txt = format!("{:#^0100E}", a_biguint);
assert_eq!(txt, "00000000000000000001.2345678901234567890123456789012345678901234567890123456789012345678901234567E76");
§Example 46
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:$^20.9E}", a_biguint);
let txt = format!("{:$^20.9E}", a_biguint);
assert_eq!(txt, "$$$1.234567890E76$$$");
§Example 47
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:%^020.9E}", a_biguint);
let txt = format!("{:%^020.9E}", a_biguint);
assert_eq!(txt, "0000001.234567890E76");
§Example 48
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:^^21.13E}", a_biguint);
let txt = format!("{:^^21.13E}", a_biguint);
assert_eq!(txt, "^1.2345678901235E76^^");
§Example 49
use std::str::FromStr;
use cryptocol::define_utypes_with;
define_utypes_with!(u8);
 
let a_biguint = U256::from_str("12345678901234567890123456789012345678901234567890123456789012345678901234567").unwrap();
println!("{:&^021.13E}", a_biguint);
let txt = format!("{:&^021.13E}", a_biguint);
assert_eq!(txt, "0001.2345678901235E76");

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for BigUInt<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for BigUInt<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> Send for BigUInt<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for BigUInt<T, N>
where T: Sync,

§

impl<T, const N: usize> Unpin for BigUInt<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for BigUInt<T, N>
where T: UnwindSafe,

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.