Crate ibig[−][src]
Big integer library.
The library implements arbitrarily large integer arithmetic in pure Rust.
The two integer types are UBig (for unsigned integers) and IBig (for signed integers).
Create numbers using the ubig and ibig macros.
use ibig::prelude::*; let a = ubig!(12345678); let b = ubig!(0x10ff); let c = ibig!(-azz base 36); assert_eq!(c.to_string(), "-14255");
Parsing and formatting in any base 2-36 is supported.
let a: UBig = "1503321".parse()?; let b = IBig::from_str_radix("-10ff", 16)?; assert_eq!(format!("{:^10X}", b), " -10FF "); assert_eq!(format!("hello {}", b.in_radix(4)), "hello -1003333");
Standard arithmetic operations are supported on values and on references.
assert_eq!(ubig!(100) * ubig!(200), ubig!(20000)); let a = ubig!(0xff); assert_eq!(&a / &a, ubig!(1)); assert_eq!(ibig!(1) << 1000 >> 999, ibig!(2));
Modules
prelude | Reexports the most useful names. |
Macros
ibig | Create an |
ubig | Create a |
Structs
IBig | Signed big integer. |
InRadix | Representation of a |
OutOfBoundsError | Number out of bounds. |
UBig | Unsigned big integer. |
Enums
ParseError | Parse error when parsing |
Traits
Abs | Absolute value. |
AndNot | Bitwise AND NOT operation. |
DivEuclid | Compute Euclidean quotient. |
DivRem | Compute quotient and remainder at the same time. |
DivRemEuclid | Compute Euclidean quotient and remainder at the same time. |
NextPowerOfTwo | Next power of two. |
RemEuclid | Compute Euclidean remainder. |
UnsignedAbs | Unsigned absolute value. |