Struct rug::Integer
[−]
[src]
pub struct Integer { /* fields omitted */ }
An arbitrary-precision integer.
Standard arithmetic operations, bitwise operations and comparisons
are supported. In standard arithmetic operations such as addition,
you can mix Integer
and primitive integer types; the result will
be an Integer
.
Internally the integer is not stored using two’s-complement representation, however, for bitwise operations and shifts, the functionality is the same as if the representation was using two’s complement.
Examples
use rug::{Assign, Integer}; // Create an integer initialized as zero. let mut int = Integer::new(); assert_eq!(int, 0); assert_eq!(int.to_u32(), Some(0)); int.assign(-14); assert_eq!(int, -14); assert_eq!(int.to_u32(), None); assert_eq!(int.to_i32(), Some(-14));
Arithmetic operations with mixed arbitrary and primitive types are
allowed. Note that in the following example, there is only one
allocation. The Integer
instance is moved into the shift
operation so that the result can be stored in the same instance,
then that result is similarly consumed by the addition operation.
use rug::Integer; let mut a = Integer::from(0xc); a = (a << 80) + 0xffee; assert_eq!(a.to_string_radix(16), "c0000000000000000ffee"); // ^ ^ ^ ^ ^ // 80 64 48 32 16
Bitwise operations on Integer
values behave as if the value uses
two’s-complement representation.
use rug::Integer; let mut i = Integer::from(1); i = i << 1000; // i is now 1000000... (1000 zeros) assert_eq!(i.significant_bits(), 1001); assert_eq!(i.find_one(0), Some(1000)); i -= 1; // i is now 111111... (1000 ones) assert_eq!(i.count_ones(), Some(1000)); let a = Integer::from(0xf00d); let all_ones_xor_a = Integer::from(-1) ^ &a; // a is unchanged as we borrowed it let complement_a = !a; // now a has been moved, so this would cause an error: // assert!(a > 0); assert_eq!(all_ones_xor_a, complement_a); assert_eq!(complement_a, -0xf00e); assert_eq!(format!("{:x}", complement_a), "-f00e");
To initialize a very large Integer
, you can parse a string.
use rug::Integer; let s1 = "123456789012345678901234567890"; let i1 = s1.parse::<Integer>().unwrap(); assert_eq!(i1.significant_bits(), 97); let s2 = "ffff0000ffff0000ffff0000ffff0000ffff0000"; let i2 = Integer::from_str_radix(s2, 16).unwrap(); assert_eq!(i2.significant_bits(), 160); assert_eq!(i2.count_ones(), Some(80));
Operations on two borrowed Integer
values result in an
intermediate value that has to be assigned to a new Integer
value.
use rug::Integer; let a = Integer::from(10); let b = Integer::from(3); let a_b_ref = &a + &b; let a_b = Integer::from(a_b_ref); assert_eq!(a_b, 13);
The Integer
type supports various functions. Most functions have
two versions: one that changes the operand in place, and one that
borrows the operand.
use rug::Integer; let mut a = Integer::from(-15); // abs_ref() borrows the value let abs1 = Integer::from(a.abs_ref()); assert_eq!(abs1, 15); // abs() changes the value in place a.abs(); assert_eq!(a, 15);
Methods
impl Integer
[src]
fn new() -> Integer
Constructs a new arbitrary-precision integer with value 0.
Examples
use rug::Integer; let i = Integer::new(); assert_eq!(i, 0);
fn with_capacity(bits: usize) -> Integer
Constructs a new arbitrary-precision integer with at least the specified capacity.
Examples
use rug::Integer; let i = Integer::with_capacity(137); assert!(i.capacity() >= 137);
fn capacity(&self) -> usize
Returns the capacity in bits that can be stored without reallocating.
Examples
use rug::Integer; let i = Integer::with_capacity(137); assert!(i.capacity() >= 137);
fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more bits in the
Integer
. If the integer already has enough excess capacity,
this function does nothing.
Examples
use rug::Integer; // 0x2000_0000 needs 30 bits. let mut i = Integer::from(0x2000_0000); i.reserve(34); let capacity = i.capacity(); assert!(capacity >= 64); i.reserve(34); assert!(i.capacity() == capacity); i.reserve(35); assert!(i.capacity() >= 65);
fn shrink_to_fit(&mut self)
Reserves capacity for at least additional
more bits in the
Integer
. If the integer already has enough excess capacity,
this function does nothing.
Examples
use rug::Integer; // let i be 100 bits wide let mut i = Integer::from_str_radix("fffff12345678901234567890", 16) .unwrap(); assert!(i.capacity() >= 100); i >>= 80; i.shrink_to_fit(); assert!(i.capacity() >= 20);
fn from_f32(val: f32) -> Option<Integer>
Creates an Integer
from an f32
if it is finite, rounding
towards zero.
Examples
use rug::Integer; use std::f32; let i = Integer::from_f32(-5.6).unwrap(); assert_eq!(i, -5); let neg_inf = Integer::from_f32(f32::NEG_INFINITY); assert!(neg_inf.is_none());
fn from_f64(val: f64) -> Option<Integer>
Creates an Integer
from an f64
if it is finite, rounding
towards zero.
Examples
use rug::Integer; use std::f64; let i = Integer::from_f64(1e20).unwrap(); assert_eq!(i, "100000000000000000000".parse::<Integer>().unwrap()); let inf = Integer::from_f64(f64::INFINITY); assert!(inf.is_none());
fn from_str_radix(src: &str, radix: i32) -> Result<Integer, ParseIntegerError>
Parses an Integer
using the given radix.
Examples
use rug::Integer; let i = Integer::from_str_radix("-ff", 16).unwrap(); assert_eq!(i, -0xff);
Panics
Panics if radix
is less than 2 or greater than 36.
fn valid_str_radix(
src: &str,
radix: i32
) -> Result<ValidInteger, ParseIntegerError>
src: &str,
radix: i32
) -> Result<ValidInteger, ParseIntegerError>
Checks if an Integer
can be parsed.
If this method does not return an error, neither will any
other function that parses an Integer
. If this method
returns an error, the other functions will return the same
error.
The string can start with an optional minus or plus sign. Whitespace is not allowed anywhere in the string, including in the beginning and end.
Examples
use rug::Integer; let valid1 = Integer::valid_str_radix("1223", 4); let i1 = Integer::from(valid1.unwrap()); assert_eq!(i1, 3 + 4 * (2 + 4 * (2 + 4 * 1))); let valid2 = Integer::valid_str_radix("12yz", 36); let i2 = Integer::from(valid2.unwrap()); assert_eq!(i2, 35 + 36 * (34 + 36 * (2 + 36 * 1))); let invalid = Integer::valid_str_radix("123", 3); let invalid_f = Integer::from_str_radix("123", 3); assert_eq!(invalid.unwrap_err(), invalid_f.unwrap_err());
Panics
Panics if radix
is less than 2 or greater than 36.
fn to_i32(&self) -> Option<i32>
Converts to an i32
if the value fits.
Examples
use rug::Integer; let fits = Integer::from(-50); assert_eq!(fits.to_i32(), Some(-50)); let small = Integer::from(-123456789012345_i64); assert_eq!(small.to_i32(), None); let large = Integer::from(123456789012345_u64); assert_eq!(large.to_i32(), None);
fn to_i64(&self) -> Option<i64>
Converts to an i64
if the value fits.
Examples
use rug::Integer; let fits = Integer::from(-50); assert_eq!(fits.to_i64(), Some(-50)); let small = Integer::from_str_radix("-fedcba9876543210", 16).unwrap(); assert_eq!(small.to_i64(), None); let large = Integer::from_str_radix("fedcba9876543210", 16).unwrap(); assert_eq!(large.to_i64(), None);
fn to_u32(&self) -> Option<u32>
Converts to a u32
if the value fits.
Examples
use rug::Integer; let fits = Integer::from(1234567890); assert_eq!(fits.to_u32(), Some(1234567890)); let neg = Integer::from(-1); assert_eq!(neg.to_u32(), None); let large = "123456789012345".parse::<Integer>().unwrap(); assert_eq!(large.to_u32(), None);
fn to_u64(&self) -> Option<u64>
Converts to a u64
if the value fits.
Examples
use rug::Integer; let fits = Integer::from(123456789012345_u64); assert_eq!(fits.to_u64(), Some(123456789012345)); let neg = Integer::from(-1); assert_eq!(neg.to_u64(), None); let large = "1234567890123456789012345".parse::<Integer>().unwrap(); assert_eq!(large.to_u64(), None);
fn to_i32_wrapping(&self) -> i32
Converts to an i32
, wrapping if the value does not fit.
Examples
use rug::Integer; let fits = Integer::from(-0xabcdef_i32); assert_eq!(fits.to_i32_wrapping(), -0xabcdef); let small = Integer::from(0x1_ffff_ffff_u64); assert_eq!(small.to_i32_wrapping(), -1); let large = Integer::from_str_radix("1234567890abcdef", 16).unwrap(); assert_eq!(large.to_i32_wrapping(), 0x90abcdef_u32 as i32);
fn to_i64_wrapping(&self) -> i64
Converts to an i64
, wrapping if the value does not fit.
Examples
use rug::Integer; let fits = Integer::from(-0xabcdef); assert_eq!(fits.to_i64_wrapping(), -0xabcdef); let small = Integer::from_str_radix("1ffffffffffffffff", 16).unwrap(); assert_eq!(small.to_i64_wrapping(), -1); let large = Integer::from_str_radix("f1234567890abcdef", 16).unwrap(); assert_eq!(large.to_i64_wrapping(), 0x1234567890abcdef_i64);
fn to_u32_wrapping(&self) -> u32
Converts to a u32
, wrapping if the value does not fit.
Examples
use rug::Integer; let fits = Integer::from(0x90abcdef_u32); assert_eq!(fits.to_u32_wrapping(), 0x90abcdef); let neg = Integer::from(-1); assert_eq!(neg.to_u32_wrapping(), 0xffffffff); let large = Integer::from_str_radix("1234567890abcdef", 16).unwrap(); assert_eq!(large.to_u32_wrapping(), 0x90abcdef);
fn to_u64_wrapping(&self) -> u64
Converts to a u64
, wrapping if the value does not fit.
Examples
use rug::Integer; let fits = Integer::from(0x90abcdef_u64); assert_eq!(fits.to_u64_wrapping(), 0x90abcdef); let neg = Integer::from(-1); assert_eq!(neg.to_u64_wrapping(), 0xffff_ffff_ffff_ffff); let large = Integer::from_str_radix("f123456789abcdef0", 16).unwrap(); assert_eq!(large.to_u64_wrapping(), 0x123456789abcdef0);
fn to_f32(&self) -> f32
Converts to an f32
, rounding towards zero.
Examples
use rug::Integer; use std::f32; let min = Integer::from_f32(f32::MIN).unwrap(); let minus_one = min - 1u32; // minus_one is truncated to f32::MIN assert_eq!(minus_one.to_f32(), f32::MIN); let times_two = minus_one * 2u32; // times_two is too small assert_eq!(times_two.to_f32(), f32::NEG_INFINITY);
fn to_f64(&self) -> f64
Converts to an f64
, rounding towards zero.
Examples
use rug::Integer; use std::f64; // An `f64` has 53 bits of precision. let exact = 0x1f_ffff_ffff_ffff_u64; let i = Integer::from(exact); assert_eq!(i.to_f64(), exact as f64); // large has 56 ones let large = 0xff_ffff_ffff_ffff_u64; // trunc has 53 ones followed by 3 zeros let trunc = 0xff_ffff_ffff_fff8_u64; let j = Integer::from(large); assert_eq!(j.to_f64(), trunc as f64); let max = Integer::from_f64(f64::MAX).unwrap(); let plus_one = max + 1u32; // plus_one is truncated to f64::MAX assert_eq!(plus_one.to_f64(), f64::MAX); let times_two = plus_one * 2u32; // times_two is too large assert_eq!(times_two.to_f64(), f64::INFINITY);
fn to_f32_exp(&self) -> (f32, u32)
Converts to an f32
and an exponent, rounding towards zero.
The returned f32
is in the range 0.5 ≤ x < 1.
Examples
use rug::Integer; let zero = Integer::new(); let (d0, exp0) = zero.to_f32_exp(); assert_eq!((d0, exp0), (0.0, 0)); let fifteen = Integer::from(15); let (d15, exp15) = fifteen.to_f32_exp(); assert_eq!((d15, exp15), (15.0 / 16.0, 4));
fn to_f64_exp(&self) -> (f64, u32)
Converts to an f64
and an exponent, rounding towards zero.
The returned f64
is in the range 0.5 ≤ x < 1.
Examples
use rug::Integer; let zero = Integer::new(); let (d0, exp0) = zero.to_f64_exp(); assert_eq!((d0, exp0), (0.0, 0)); let fifteen = Integer::from(15); let (d15, exp15) = fifteen.to_f64_exp(); assert_eq!((d15, exp15), (15.0 / 16.0, 4));
fn to_string_radix(&self, radix: i32) -> String
Returns a string representation of the number for the
specified radix
.
Examples
use rug::{Assign, Integer}; let mut i = Integer::new(); assert_eq!(i.to_string_radix(10), "0"); i.assign(-10); assert_eq!(i.to_string_radix(16), "-a"); i.assign(0x1234cdef); assert_eq!(i.to_string_radix(4), "102031030313233"); i.assign_str_radix("1234567890aAbBcCdDeEfF", 16).unwrap(); assert_eq!(i.to_string_radix(16), "1234567890aabbccddeeff");
Panics
Panics if radix
is less than 2 or greater than 36.
fn assign_f32(&mut self, val: f32) -> Result<(), ()>
Assigns from an f32
if it is finite, rounding towards zero.
Examples
use rug::Integer; use std::f32; let mut i = Integer::new(); let ret = i.assign_f64(-12.7); assert!(ret.is_ok()); assert_eq!(i, -12); let ret = i.assign_f32(f32::NAN); assert!(ret.is_err()); assert_eq!(i, -12);
fn assign_f64(&mut self, val: f64) -> Result<(), ()>
Assigns from an f64
if it is finite, rounding towards zero.
Examples
use rug::Integer; let mut i = Integer::new(); let ret = i.assign_f64(12.7); assert!(ret.is_ok()); assert_eq!(i, 12); let ret = i.assign_f64(1.0 / 0.0); assert!(ret.is_err()); assert_eq!(i, 12);
fn assign_str(&mut self, src: &str) -> Result<(), ParseIntegerError>
Parses an Integer
from a string in decimal.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_str("123").unwrap(); assert_eq!(i, 123); let ret = i.assign_str("bad"); assert!(ret.is_err());
fn assign_str_radix(
&mut self,
src: &str,
radix: i32
) -> Result<(), ParseIntegerError>
&mut self,
src: &str,
radix: i32
) -> Result<(), ParseIntegerError>
Parses an Integer
from a string with the specified radix.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_str_radix("ff", 16).unwrap(); assert_eq!(i, 0xff);
Panics
Panics if radix
is less than 2 or greater than 36.
fn is_even(&self) -> bool
Returns true
if the number is even.
Examples
use rug::Integer; assert!(!(Integer::from(13).is_even())); assert!(Integer::from(-14).is_even());
fn is_odd(&self) -> bool
Returns true
if the number is odd.
Examples
use rug::Integer; assert!(Integer::from(13).is_odd()); assert!(!Integer::from(-14).is_odd());
fn is_divisible(&self, divisor: &Integer) -> bool
Returns true
if the number is divisible by divisor
. Unlike
other division functions, divisor
can be zero.
Examples
use rug::Integer; let i = Integer::from(230); assert!(i.is_divisible(&Integer::from(10))); assert!(!i.is_divisible(&Integer::from(100))); assert!(!i.is_divisible(&Integer::new()));
fn is_divisible_u(&self, divisor: u32) -> bool
Returns true
if the number is divisible by divisor
. Unlike
other division functions, divisor
can be zero.
Examples
use rug::Integer; let i = Integer::from(230); assert!(i.is_divisible_u(23)); assert!(!i.is_divisible_u(100)); assert!(!i.is_divisible_u(0));
fn is_divisible_2pow(&self, b: u32) -> bool
Returns true
if the number is divisible by two to the power
of b
.
Examples
use rug::Integer; let i = Integer::from(15 << 17); assert!(i.is_divisible_2pow(16)); assert!(i.is_divisible_2pow(17)); assert!(!i.is_divisible_2pow(18));
fn is_congruent(&self, c: &Integer, divisor: &Integer) -> bool
Returns true
if the number is congruent to c
modulo
divisor
, that is, if there exists a q
such that
self == c + q * divisor
. Unlike other division functions,
divisor
can be zero.
Examples
use rug::Integer; let n = Integer::from(105); let divisor = Integer::from(10); assert!(n.is_congruent(&Integer::from(5), &divisor)); assert!(n.is_congruent(&Integer::from(25), &divisor)); assert!(!n.is_congruent(&Integer::from(7), &divisor)); // n is congruent to itself if divisor is 0 assert!(n.is_congruent(&n, &Integer::from(0)));
fn is_congruent_u(&self, c: u32, divisor: u32) -> bool
Returns true
if the number is congruent to c
modulo
divisor
, that is, if there exists a q
such that
self == c + q * divisor
. Unlike other division functions,
divisor
can be zero.
Examples
use rug::Integer; let n = Integer::from(105); assert!(n.is_congruent_u(3335, 10)); assert!(!n.is_congruent_u(107, 10)); // n is congruent to itself if divisor is 0 assert!(n.is_congruent_u(105, 0));
fn is_congruent_2pow(&self, c: &Integer, b: u32) -> bool
Returns true
if the number is congruent to c
modulo two to
the power of b
, that is, if there exists a q
such that
self == c + q * 2 ^ b
.
Examples
use rug::Integer; let n = Integer::from(13 << 17 | 21); assert!(n.is_congruent_2pow(&Integer::from(7 << 17 | 21), 17)); assert!(!n.is_congruent_2pow(&Integer::from(13 << 17 | 22), 17));
fn is_perfect_power(&self) -> bool
Returns true
if the number is a perfect power.
Examples
use rug::{Assign, Integer}; // 0 is 0 to the power of anything let mut i = Integer::from(0); assert!(i.is_perfect_power()); // 243 is 3 to the power of 5 i.assign(243); assert!(i.is_perfect_power()); // 10 is not a perfect power i.assign(10); assert!(!i.is_perfect_power());
fn is_perfect_square(&self) -> bool
Returns true
if the number is a perfect square.
Examples
use rug::{Assign, Integer}; let mut i = Integer::from(1); assert!(i.is_perfect_square()); i.assign(9); assert!(i.is_perfect_square()); i.assign(15); assert!(!i.is_perfect_square());
fn sign(&self) -> Ordering
Returns the same result as self.cmp(0), but is faster.
Examples
use rug::Integer; use std::cmp::Ordering; assert_eq!(Integer::from(-5).sign(), Ordering::Less); assert_eq!(Integer::from(0).sign(), Ordering::Equal); assert_eq!(Integer::from(5).sign(), Ordering::Greater);
fn cmp_abs(&self, other: &Integer) -> Ordering
Compares the absolute values.
Examples
use rug::Integer; use std::cmp::Ordering; let a = Integer::from(-10); let b = Integer::from(4); assert_eq!(a.cmp(&b), Ordering::Less); assert_eq!(a.cmp_abs(&b), Ordering::Greater);
fn significant_bits(&self) -> u32
Returns the number of bits required to represent the absolute value.
Examples
use rug::Integer; assert_eq!(Integer::from(0).significant_bits(), 0); assert_eq!(Integer::from(1).significant_bits(), 1); assert_eq!(Integer::from(-1).significant_bits(), 1); assert_eq!(Integer::from(4).significant_bits(), 3); assert_eq!(Integer::from(-4).significant_bits(), 3); assert_eq!(Integer::from(7).significant_bits(), 3); assert_eq!(Integer::from(-7).significant_bits(), 3);
fn count_ones(&self) -> Option<u32>
Returns the number of one bits if the value >= 0.
Examples
use rug::Integer; assert_eq!(Integer::from(0).count_ones(), Some(0)); assert_eq!(Integer::from(15).count_ones(), Some(4)); assert_eq!(Integer::from(-1).count_ones(), None);
fn count_zeros(&self) -> Option<u32>
Returns the number of zero bits if the value < 0.
Examples
use rug::Integer; assert_eq!(Integer::from(0).count_zeros(), None); assert_eq!(Integer::from(1).count_zeros(), None); assert_eq!(Integer::from(-1).count_zeros(), Some(0)); assert_eq!(Integer::from(-2).count_zeros(), Some(1)); assert_eq!(Integer::from(-7).count_zeros(), Some(2)); assert_eq!(Integer::from(-8).count_zeros(), Some(3));
fn find_zero(&self, start: u32) -> Option<u32>
Returns the location of the first zero, starting at start
.
If the bit at location start
is zero, returns start
.
use rug::Integer; assert_eq!(Integer::from(-2).find_zero(0), Some(0)); assert_eq!(Integer::from(-2).find_zero(1), None); assert_eq!(Integer::from(15).find_zero(0), Some(4)); assert_eq!(Integer::from(15).find_zero(20), Some(20));
fn find_one(&self, start: u32) -> Option<u32>
Returns the location of the first one, starting at start
.
If the bit at location start
is one, returns start
.
use rug::Integer; assert_eq!(Integer::from(1).find_one(0), Some(0)); assert_eq!(Integer::from(1).find_one(1), None); assert_eq!(Integer::from(-16).find_one(0), Some(4)); assert_eq!(Integer::from(-16).find_one(20), Some(20));
fn set_bit(&mut self, index: u32, val: bool) -> &mut Integer
Sets the bit at location index
to 1 if val
is true
or 0
if val
is false
.
Examples
use rug::{Assign, Integer}; let mut i = Integer::from(-1); assert_eq!(*i.set_bit(0, false), -2); i.assign(0xff); assert_eq!(*i.set_bit(11, true), 0x8ff);
fn get_bit(&self, index: u32) -> bool
Returns true
if the bit at location index
is 1 or false
if the bit is 0.
Examples
use rug::Integer; let i = Integer::from(0b100101); assert!(i.get_bit(0)); assert!(!i.get_bit(1)); assert!(i.get_bit(5)); let neg = Integer::from(-1); assert!(neg.get_bit(1000));
fn toggle_bit(&mut self, index: u32) -> &mut Integer
Toggles the bit at location index
.
Examples
use rug::Integer; let mut i = Integer::from(0b100101); i.toggle_bit(5); assert_eq!(i, 0b101);
fn hamming_dist(&self, other: &Integer) -> Option<u32>
Retuns the Hamming distance if the two numbers have the same sign.
Examples
use rug::Integer; let i = Integer::from(-1); assert_eq!(Integer::from(0).hamming_dist(&i), None); assert_eq!(Integer::from(-1).hamming_dist(&i), Some(0)); assert_eq!(Integer::from(-13).hamming_dist(&i), Some(2));
fn abs(&mut self) -> &mut Integer
Computes the absolute value.
Examples
use rug::Integer; let mut i = Integer::from(-100); assert_eq!(*i.abs(), 100); assert_eq!(i, 100);
fn abs_ref(&self) -> AbsRef
Computes the absolute value.
Examples
use rug::Integer; let i = Integer::from(-100); let r = i.abs_ref(); let abs = Integer::from(r); assert_eq!(abs, 100); assert_eq!(i, -100);
fn keep_bits(&mut self, n: u32) -> &mut Integer
Keeps the n
least significant bits only.
Examples
use rug::Integer; let mut i = Integer::from(-1); assert_eq!(*i.keep_bits(8), 0xff);
fn keep_bits_ref(&self, n: u32) -> KeepBitsRef
Keeps the n
least significant bits only.
Examples
use rug::Integer; let i = Integer::from(-1); let r = i.keep_bits_ref(8); let eight_bits = Integer::from(r); assert_eq!(eight_bits, 0xff);
fn next_power_of_two(&mut self) -> &mut Integer
Finds the next power of two, or 1 if the number ≤ 0.
Examples
use rug::{Assign, Integer}; let mut i = Integer::from(-3); assert_eq!(*i.next_power_of_two(), 1); i.assign(4); assert_eq!(*i.next_power_of_two(), 4); i.assign(7); assert_eq!(*i.next_power_of_two(), 8);
fn next_power_of_two_ref(&self) -> NextPowerTwoRef
Finds the next power of two, or 1 if the number ≤ 0.
Examples
use rug::Integer; let i = Integer::from(53); let r = i.next_power_of_two_ref(); let next = Integer::from(r); assert_eq!(next, 64);
fn div_rem(&mut self, divisor: &mut Integer)
Performs a division and stores the quotient in self
and
the remainder in divisor
.
Examples
use rug::Integer; let mut quotient = Integer::from(23); let mut rem = Integer::from(10); quotient.div_rem(&mut rem); assert_eq!(quotient, 2); assert_eq!(rem, 3);
Panics
Panics if divisor
is zero.
fn div_rem_ref<'a>(&'a self, divisor: &'a Integer) -> DivRemRef<'a>
Performs a division and returns the quotient and remainder.
Examples
use rug::{Assign, Integer}; let dividend = Integer::from(23); let divisor = Integer::from(10); let r = dividend.div_rem_ref(&divisor); let (mut quotient, mut rem) = (Integer::new(), Integer::new()); (&mut quotient, &mut rem).assign(r); assert_eq!(quotient, 2); assert_eq!(rem, 3);
fn div_exact(&mut self, divisor: &Integer) -> &mut Integer
Performs an exact division. This is much faster than normal division, but produces correct results only when the division is exact.
Examples
use rug::Integer; let mut i = Integer::from(12345 * 54321); assert_eq!(*i.div_exact(&Integer::from(12345)), 54321); assert_eq!(i, 54321);
Panics
Panics if divisor
is zero.
fn div_exact_ref<'a>(&'a self, divisor: &'a Integer) -> DivExactRef<'a>
Performs an exact division. This is much faster than normal division, but produces correct results only when the division is exact.
Examples
use rug::Integer; let i = Integer::from(12345 * 54321); let divisor = Integer::from(12345); let r = i.div_exact_ref(&divisor); let q = Integer::from(r); assert_eq!(q, 54321);
fn div_exact_u(&mut self, divisor: u32) -> &mut Integer
Performs an exact division. This is much faster than normal division, but produces correct results only when the division is exact.
Examples
use rug::Integer; let mut i = Integer::from(12345 * 54321); assert_eq!(*i.div_exact_u(12345), 54321);
Panics
Panics if divisor
is zero.
fn div_exact_u_ref(&self, divisor: u32) -> DivExactURef
Performs an exact division. This is much faster than normal division, but produces correct results only when the division is exact.
Examples
use rug::Integer; let i = Integer::from(12345 * 54321); let r = i.div_exact_u_ref(12345); assert_eq!(Integer::from(r), 54321);
fn invert(&mut self, modulo: &Integer) -> bool
Finds the inverse modulo modulo
and returns true
if an
inverse exists.
Examples
use rug::Integer; let mut n = Integer::from(2); // Modulo 4, 2 has no inverse: there is no x such that 2 * x = 1. let exists_4 = n.invert(&Integer::from(4)); assert!(!exists_4); assert_eq!(n, 2); // Modulo 5, the inverse of 2 is 3, as 2 * 3 = 1. let exists_5 = n.invert(&Integer::from(5)); assert!(exists_5); assert_eq!(n, 3);
Panics
Panics if modulo
is zero.
fn invert_ref<'a>(&'a self, modulo: &'a Integer) -> InvertRef<'a>
Finds the inverse modulo modulo
if an inverse exists.
Examples
use rug::{Assign, Integer}; let n = Integer::from(2); // Modulo 4, 2 has no inverse, there is no x such that 2 * x = 1. let (mut inv_4, mut exists_4) = (Integer::new(), false); (&mut inv_4, &mut exists_4).assign(n.invert_ref(&Integer::from(4))); assert!(!exists_4); // Modulo 5, the inverse of 2 is 3, as 2 * 3 = 1. let (mut inv_5, mut exists_5) = (Integer::new(), false); (&mut inv_5, &mut exists_5).assign(n.invert_ref(&Integer::from(5))); assert!(exists_5); assert_eq!(inv_5, 3);
fn pow_mod(&mut self, power: &Integer, modulo: &Integer) -> bool
Raises a number to the power of power
modulo modulo
and
return true
if an answer exists.
If power
is negative, then the number must have an inverse
modulo modulo
for an answer to exist.
Examples
use rug::{Assign, Integer}; // 7 ^ 5 = 16807 let mut n = Integer::from(7); let pow = Integer::from(5); let m = Integer::from(1000); assert!(n.pow_mod(&pow, &m)); assert_eq!(n, 807); // 7 * 143 modulo 1000 = 1, so 7 has an inverse 143. // 7 ^ -5 modulo 1000 = 143 ^ 5 modulo 1000 = 943. n.assign(7); let neg_pow = Integer::from(-5); assert!(n.pow_mod(&neg_pow, &m)); assert_eq!(n, 943);
fn pow_mod_ref<'a>(
&'a self,
power: &'a Integer,
modulo: &'a Integer
) -> PowModRef<'a>
&'a self,
power: &'a Integer,
modulo: &'a Integer
) -> PowModRef<'a>
Raises a number to the power of power
modulo modulo
and
return true
if an answer exists.
If power
is negative, then the number must have an inverse
modulo modulo
for an answer to exist.
Examples
use rug::{Assign, Integer}; // 7 ^ 5 = 16807 let base = Integer::from(7); let pow = Integer::from(5); let m = Integer::from(1000); let r = base.pow_mod_ref(&pow, &m); let (mut ans, mut exists) = (Integer::new(), false); (&mut ans, &mut exists).assign(r); assert!(exists); assert_eq!(ans, 807);
fn assign_u_pow_u(&mut self, base: u32, power: u32)
Raises base
to the power of power
.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_u_pow_u(13, 12); assert_eq!(i, 13_u64.pow(12));
fn assign_i_pow_u(&mut self, base: i32, power: u32)
Raises base
to the power of power
.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_i_pow_u(-13, 12); assert_eq!(i, (-13_i64).pow(12)); i.assign_i_pow_u(-13, 13); assert_eq!(i, (-13_i64).pow(13));
fn root(&mut self, n: u32) -> &mut Integer
Computes the n
th root and truncates the result.
Examples
use rug::Integer; let mut i = Integer::from(1004); assert_eq!(*i.root(3), 10);
fn root_ref(&self, n: u32) -> RootRef
Computes the n
th root and truncates the result.
Examples
use rug::Integer; let i = Integer::from(1004); assert_eq!(Integer::from(i.root_ref(3)), 10);
fn root_rem(&mut self, remainder: &mut Integer, n: u32)
Computes the n
th root and returns the truncated root and
the remainder.
The remainder is the original number minus the truncated
root raised to the power of n
.
Examples
use rug::Integer; let mut i = Integer::from(1004); let mut rem = Integer::new(); i.root_rem(&mut rem, 3); assert_eq!(i, 10); assert_eq!(rem, 4);
fn root_rem_ref(&self, n: u32) -> RootRemRef
Computes the n
th root and returns the truncated root and
the remainder.
The remainder is the original number minus the truncated
root raised to the power of n
.
Examples
use rug::{Assign, Integer}; let i = Integer::from(1004); let r = i.root_rem_ref(3); let mut root = Integer::new(); let mut rem = Integer::new(); (&mut root, &mut rem).assign(r); assert_eq!(root, 10); assert_eq!(rem, 4);
fn sqrt(&mut self) -> &mut Integer
Computes the square root and truncates the result.
Examples
use rug::Integer; let mut i = Integer::from(104); assert_eq!(*i.sqrt(), 10);
fn sqrt_ref(&self) -> SqrtRef
Computes the square root and truncates the result.
Examples
use rug::Integer; let i = Integer::from(104); assert_eq!(Integer::from(i.sqrt_ref()), 10);
fn sqrt_rem(&mut self, remainder: &mut Integer)
Computes the square root and the remainder. The remainder is the original number minus the truncated root squared.
Examples
use rug::Integer; let mut i = Integer::from(104); let mut rem = Integer::new(); i.sqrt_rem(&mut rem); assert_eq!(i, 10); assert_eq!(rem, 4);
fn sqrt_rem_ref(&self) -> SqrtRemRef
Computes the square root and the remainder. The remainder is the original number minus the truncated root squared.
Examples
use rug::{Assign, Integer}; let i = Integer::from(104); let r = i.sqrt_rem_ref(); let mut root = Integer::new(); let mut rem = Integer::new(); (&mut root, &mut rem).assign(r); assert_eq!(root, 10); assert_eq!(rem, 4);
fn is_probably_prime(&self, reps: u32) -> IsPrime
Determines wheter a number is prime using some trial
divisions, then reps
Miller-Rabin probabilistic primality
tests.
Examples
use rug::Integer; use rug::integer::IsPrime; let no = Integer::from(163 * 4003); assert_eq!(no.is_probably_prime(15), IsPrime::No); let yes = Integer::from(21_751); assert_eq!(yes.is_probably_prime(15), IsPrime::Yes); // 817_504_243 is actually a prime. let probably = Integer::from(817_504_243); assert_eq!(probably.is_probably_prime(15), IsPrime::Probably);
fn next_prime(&mut self) -> &mut Integer
Identifies primes using a probabilistic algorithm; the chance of a composite passing will be extremely small.
fn next_prime_ref(&self) -> NextPrimeRef
Identifies primes using a probabilistic algorithm; the chance of a composite passing will be extremely small.
fn gcd(&mut self, other: &Integer) -> &mut Integer
Finds the greatest common divisor.
The result is always positive except when both inputs are zero.
Examples
use rug::{Assign, Integer}; let mut a = Integer::new(); let mut b = Integer::new(); a.gcd(&b); // gcd of 0, 0 is 0 assert_eq!(*a.gcd(&b), 0); b.assign(10); // gcd of 0, 10 is 10 assert_eq!(*a.gcd(&b), 10); b.assign(25); // gcd of 10, 25 is 5 assert_eq!(*a.gcd(&b), 5);
fn gcd_ref<'a>(&'a self, other: &'a Integer) -> GcdRef<'a>
Finds the greatest common divisor.
Examples
use rug::Integer; let a = Integer::from(100); let b = Integer::from(125); let r = a.gcd_ref(&b); // gcd of 100, 125 is 25 assert_eq!(Integer::from(r), 25);
fn lcm(&mut self, other: &Integer) -> &mut Integer
Finds the least common multiple.
The result is always positive except when one or both inputs are zero.
Examples
use rug::{Assign, Integer}; let mut a = Integer::from(10); let mut b = Integer::from(25); // lcm of 10, 25 is 50 assert_eq!(*a.lcm(&b), 50); b.assign(0); // lcm of 50, 0 is 0 assert_eq!(*a.lcm(&b), 0);
fn lcm_ref<'a>(&'a self, other: &'a Integer) -> LcmRef<'a>
Finds the least common multiple.
Examples
use rug::Integer; let a = Integer::from(100); let b = Integer::from(125); let r = a.lcm_ref(&b); // lcm of 100, 125 is 500 assert_eq!(Integer::from(r), 500);
fn jacobi(&self, n: &Integer) -> i32
Calculates the Jacobi symbol (self
/n
).
fn legendre(&self, p: &Integer) -> i32
Calculates the Legendre symbol (self
/p
).
fn kronecker(&self, n: &Integer) -> i32
Calculates the Jacobi symbol (self
/n
) with the
Kronecker extension.
fn remove_factor(&mut self, factor: &Integer) -> u32
Removes all occurrences of factor
, and returns the number of
occurrences removed.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_u_pow_u(13, 50); i *= 1000; let count = i.remove_factor(&Integer::from(13)); assert_eq!(count, 50); assert_eq!(i, 1000);
fn remove_factor_ref<'a>(&'a self, factor: &'a Integer) -> RemoveFactorRef<'a>
Removes all occurrences of factor
, and counts the number of
occurrences removed.
Examples
use rug::{Assign, Integer}; let mut i = Integer::new(); i.assign_u_pow_u(13, 50); i *= 1000; let (mut j, mut count) = (Integer::new(), 0); (&mut j, &mut count).assign(i.remove_factor_ref(&Integer::from(13))); assert_eq!(count, 50); assert_eq!(j, 1000);
fn assign_factorial(&mut self, n: u32)
Computes the factorial of n
.
Examples
use rug::Integer; let mut i = Integer::new(); // 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 i.assign_factorial(10); assert_eq!(i, 3628800);
fn assign_factorial_2(&mut self, n: u32)
Computes the double factorial of n
.
Examples
use rug::Integer; let mut i = Integer::new(); // 10 * 8 * 6 * 4 * 2 i.assign_factorial_2(10); assert_eq!(i, 3840);
fn assign_factorial_m(&mut self, n: u32, m: u32)
Computes the m
-multi factorial of n
.
Examples
use rug::Integer; let mut i = Integer::new(); // 10 * 7 * 4 * 1 i.assign_factorial_m(10, 3); assert_eq!(i, 280);
fn assign_primorial(&mut self, n: u32)
Computes the primorial of n
.
Examples
use rug::Integer; let mut i = Integer::new(); // 7 * 5 * 3 * 2 i.assign_primorial(10); assert_eq!(i, 210);
fn binomial(&mut self, k: u32) -> &mut Integer
Computes the binomial coefficient over k
.
Examples
use rug::Integer; // 7 choose 2 is 21 let mut i = Integer::from(7); assert_eq!(*i.binomial(2), 21);
fn binomial_ref(&self, k: u32) -> BinomialRef
Computes the binomial coefficient over k
.
Examples
use rug::Integer; // 7 choose 2 is 21 let i = Integer::from(7); assert_eq!(Integer::from(i.binomial_ref(2)), 21);
fn assign_binomial_u(&mut self, n: u32, k: u32)
Computes the binomial coefficient n
over k
.
Examples
use rug::Integer; // 7 choose 2 is 21 let mut i = Integer::new(); i.assign_binomial_u(7, 2); assert_eq!(i, 21);
fn assign_fibonacci(&mut self, n: u32)
Computes the Fibonacci number.
This function is meant for an isolated number. If a sequence
of Fibonacci numbers is required, the first two values of the
sequence should be computed with assign_fibonacci_2()
, then
iterations should be used.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_fibonacci(12); assert_eq!(i, 144);
fn assign_fibonacci_2(&mut self, previous: &mut Integer, n: u32)
Computes a Fibonacci number, and the previous Fibonacci number.
This function is meant to calculate isolated numbers. If a sequence of Fibonacci numbers is required, the first two values of the sequence should be computed with this function, then iterations should be used.
Examples
use rug::Integer; let mut i = Integer::new(); let mut j = Integer::new(); i.assign_fibonacci_2(&mut j, 12); assert_eq!(i, 144); assert_eq!(j, 89); // Fibonacci number F[-1] is 1 i.assign_fibonacci_2(&mut j, 0); assert_eq!(i, 0); assert_eq!(j, 1);
fn assign_lucas(&mut self, n: u32)
Computes the Lucas number.
This function is meant for an isolated number. If a sequence
of Lucas numbers is required, the first two values of the
sequence should be computed with assign_lucas_2()
, then
iterations should be used.
Examples
use rug::Integer; let mut i = Integer::new(); i.assign_lucas(12); assert_eq!(i, 322);
fn assign_lucas_2(&mut self, previous: &mut Integer, n: u32)
Computes a Lucas number, and the previous Lucas number.
This function is meant to calculate isolated numbers. If a sequence of Lucas numbers is required, the first two values of the sequence should be computed with this function, then iterations should be used.
Examples
use rug::Integer; let mut i = Integer::new(); let mut j = Integer::new(); i.assign_lucas_2(&mut j, 12); assert_eq!(i, 322); assert_eq!(j, 199); i.assign_lucas_2(&mut j, 0); assert_eq!(i, 2); assert_eq!(j, -1);
fn assign_random_bits(&mut self, bits: u32, rng: &mut RandState)
Generates a random number with a specified maximum number of bits.
Examples
use rug::Integer; use rug::rand::RandState; let mut rand = RandState::new(); let mut i = Integer::new(); i.assign_random_bits(0, &mut rand); assert_eq!(i, 0); i.assign_random_bits(80, &mut rand); assert!(i.significant_bits() <= 80);
fn random_below(&mut self, rng: &mut RandState) -> &mut Integer
Generates a non-negative random number below the given boundary value.
Examples
use rug::Integer; use rug::rand::RandState; let mut rand = RandState::new(); let mut i = Integer::from(15); i.random_below(&mut rand); println!("0 <= {} < 15", i); assert!(i < 15);
Panics
Panics if the boundary value is less than or equal to zero.
fn assign_random_below(&mut self, bound: &Integer, rng: &mut RandState)
Generates a non-negative random number below the given boundary value.
Examples
use rug::Integer; use rug::rand::RandState; let mut rand = RandState::new(); let bound = Integer::from(15); let mut i = Integer::new(); i.assign_random_below(&bound, &mut rand); println!("0 <= {} < {}", i, bound); assert!(i < bound);
Panics
Panics if the boundary value is less than or equal to zero.
Trait Implementations
impl Default for Integer
[src]
impl Clone for Integer
[src]
fn clone(&self) -> Integer
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Integer)
Performs copy-assignment from source
. Read more
impl Drop for Integer
[src]
impl<'a> From<&'a Integer> for Integer
[src]
impl From<i32> for Integer
[src]
impl From<i64> for Integer
[src]
impl From<u32> for Integer
[src]
impl From<u64> for Integer
[src]
impl FromStr for Integer
[src]
type Err = ParseIntegerError
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<Integer, ParseIntegerError>
Parses a string s
to return a value of this type. Read more
impl Display for Integer
[src]
impl Debug for Integer
[src]
impl Binary for Integer
[src]
impl Octal for Integer
[src]
impl LowerHex for Integer
[src]
impl UpperHex for Integer
[src]
impl Assign for Integer
[src]
impl<'a> Assign<&'a Integer> for Integer
[src]
impl Assign<i32> for Integer
[src]
impl Assign<i64> for Integer
[src]
impl Assign<u32> for Integer
[src]
impl Assign<u64> for Integer
[src]
impl<'a> From<AbsRef<'a>> for Integer
[src]
impl<'a> Assign<AbsRef<'a>> for Integer
[src]
impl<'a> From<KeepBitsRef<'a>> for Integer
[src]
impl<'a> Assign<KeepBitsRef<'a>> for Integer
[src]
impl<'a> From<NextPowerTwoRef<'a>> for Integer
[src]
impl<'a> Assign<NextPowerTwoRef<'a>> for Integer
[src]
impl<'a> From<DivExactRef<'a>> for Integer
[src]
impl<'a> Assign<DivExactRef<'a>> for Integer
[src]
impl<'a> From<DivExactURef<'a>> for Integer
[src]
impl<'a> Assign<DivExactURef<'a>> for Integer
[src]
impl<'a> From<RootRef<'a>> for Integer
[src]
impl<'a> Assign<RootRef<'a>> for Integer
[src]
impl<'a> From<SqrtRef<'a>> for Integer
[src]
impl<'a> Assign<SqrtRef<'a>> for Integer
[src]
impl<'a> From<NextPrimeRef<'a>> for Integer
[src]
impl<'a> Assign<NextPrimeRef<'a>> for Integer
[src]
impl<'a> From<GcdRef<'a>> for Integer
[src]
impl<'a> Assign<GcdRef<'a>> for Integer
[src]
impl<'a> From<LcmRef<'a>> for Integer
[src]
impl<'a> Assign<LcmRef<'a>> for Integer
[src]
impl<'a> From<BinomialRef<'a>> for Integer
[src]
impl<'a> Assign<BinomialRef<'a>> for Integer
[src]
impl Neg for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn neg(self) -> Integer
The method for the unary -
operator
impl NegAssign for Integer
[src]
fn neg_assign(&mut self)
Peforms the negation. Read more
impl<'a> Neg for &'a Integer
[src]
type Output = NegRef<'a>
The resulting type after applying the -
operator
fn neg(self) -> NegRef<'a>
The method for the unary -
operator
impl<'a> From<NegRef<'a>> for Integer
[src]
impl<'a> Assign<NegRef<'a>> for Integer
[src]
impl Add<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, op: Integer) -> Integer
The method for the +
operator
impl<'a> Add<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, op: &'a Integer) -> Integer
The method for the +
operator
impl AddAssign<Integer> for Integer
[src]
fn add_assign(&mut self, op: Integer)
The method for the +=
operator
impl<'a> AddAssign<&'a Integer> for Integer
[src]
fn add_assign(&mut self, op: &'a Integer)
The method for the +=
operator
impl<'a> Add<&'a Integer> for &'a Integer
[src]
type Output = AddRef<'a>
The resulting type after applying the +
operator
fn add(self, rhs: &'a Integer) -> AddRef<'a>
The method for the +
operator
impl<'a> From<AddRef<'a>> for Integer
[src]
impl<'a> Assign<AddRef<'a>> for Integer
[src]
impl Sub<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, op: Integer) -> Integer
The method for the -
operator
impl<'a> Sub<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, op: &'a Integer) -> Integer
The method for the -
operator
impl SubAssign<Integer> for Integer
[src]
fn sub_assign(&mut self, op: Integer)
The method for the -=
operator
impl<'a> SubAssign<&'a Integer> for Integer
[src]
fn sub_assign(&mut self, op: &'a Integer)
The method for the -=
operator
impl<'a> Sub<&'a Integer> for &'a Integer
[src]
type Output = SubRef<'a>
The resulting type after applying the -
operator
fn sub(self, rhs: &'a Integer) -> SubRef<'a>
The method for the -
operator
impl<'a> From<SubRef<'a>> for Integer
[src]
impl<'a> Assign<SubRef<'a>> for Integer
[src]
impl SubFromAssign<Integer> for Integer
[src]
fn sub_from_assign(&mut self, lhs: Integer)
Peforms the subtraction. Read more
impl<'a> SubFromAssign<&'a Integer> for Integer
[src]
fn sub_from_assign(&mut self, lhs: &'a Integer)
Peforms the subtraction. Read more
impl Mul<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the *
operator
fn mul(self, op: Integer) -> Integer
The method for the *
operator
impl<'a> Mul<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the *
operator
fn mul(self, op: &'a Integer) -> Integer
The method for the *
operator
impl MulAssign<Integer> for Integer
[src]
fn mul_assign(&mut self, op: Integer)
The method for the *=
operator
impl<'a> MulAssign<&'a Integer> for Integer
[src]
fn mul_assign(&mut self, op: &'a Integer)
The method for the *=
operator
impl<'a> Mul<&'a Integer> for &'a Integer
[src]
type Output = MulRef<'a>
The resulting type after applying the *
operator
fn mul(self, rhs: &'a Integer) -> MulRef<'a>
The method for the *
operator
impl<'a> From<MulRef<'a>> for Integer
[src]
impl<'a> Assign<MulRef<'a>> for Integer
[src]
impl Div<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the /
operator
fn div(self, op: Integer) -> Integer
The method for the /
operator
impl<'a> Div<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the /
operator
fn div(self, op: &'a Integer) -> Integer
The method for the /
operator
impl DivAssign<Integer> for Integer
[src]
fn div_assign(&mut self, op: Integer)
The method for the /=
operator
impl<'a> DivAssign<&'a Integer> for Integer
[src]
fn div_assign(&mut self, op: &'a Integer)
The method for the /=
operator
impl<'a> Div<&'a Integer> for &'a Integer
[src]
type Output = DivRef<'a>
The resulting type after applying the /
operator
fn div(self, rhs: &'a Integer) -> DivRef<'a>
The method for the /
operator
impl<'a> From<DivRef<'a>> for Integer
[src]
impl<'a> Assign<DivRef<'a>> for Integer
[src]
impl DivFromAssign<Integer> for Integer
[src]
fn div_from_assign(&mut self, lhs: Integer)
Peforms the division. Read more
impl<'a> DivFromAssign<&'a Integer> for Integer
[src]
fn div_from_assign(&mut self, lhs: &'a Integer)
Peforms the division. Read more
impl Rem<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the %
operator
fn rem(self, op: Integer) -> Integer
The method for the %
operator
impl<'a> Rem<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the %
operator
fn rem(self, op: &'a Integer) -> Integer
The method for the %
operator
impl RemAssign<Integer> for Integer
[src]
fn rem_assign(&mut self, op: Integer)
The method for the %=
operator
impl<'a> RemAssign<&'a Integer> for Integer
[src]
fn rem_assign(&mut self, op: &'a Integer)
The method for the %=
operator
impl<'a> Rem<&'a Integer> for &'a Integer
[src]
type Output = RemRef<'a>
The resulting type after applying the %
operator
fn rem(self, rhs: &'a Integer) -> RemRef<'a>
The method for the %
operator
impl<'a> From<RemRef<'a>> for Integer
[src]
impl<'a> Assign<RemRef<'a>> for Integer
[src]
impl RemFromAssign<Integer> for Integer
[src]
fn rem_from_assign(&mut self, lhs: Integer)
Peforms the remainder operation. Read more
impl<'a> RemFromAssign<&'a Integer> for Integer
[src]
fn rem_from_assign(&mut self, lhs: &'a Integer)
Peforms the remainder operation. Read more
impl Not for Integer
[src]
type Output = Integer
The resulting type after applying the !
operator
fn not(self) -> Integer
The method for the unary !
operator
impl NotAssign for Integer
[src]
fn not_assign(&mut self)
Peforms the complement. Read more
impl<'a> Not for &'a Integer
[src]
type Output = NotRef<'a>
The resulting type after applying the !
operator
fn not(self) -> NotRef<'a>
The method for the unary !
operator
impl<'a> From<NotRef<'a>> for Integer
[src]
impl<'a> Assign<NotRef<'a>> for Integer
[src]
impl BitAnd<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the &
operator
fn bitand(self, op: Integer) -> Integer
The method for the &
operator
impl<'a> BitAnd<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the &
operator
fn bitand(self, op: &'a Integer) -> Integer
The method for the &
operator
impl BitAndAssign<Integer> for Integer
[src]
fn bitand_assign(&mut self, op: Integer)
The method for the &=
operator
impl<'a> BitAndAssign<&'a Integer> for Integer
[src]
fn bitand_assign(&mut self, op: &'a Integer)
The method for the &=
operator
impl<'a> BitAnd<&'a Integer> for &'a Integer
[src]
type Output = BitAndRef<'a>
The resulting type after applying the &
operator
fn bitand(self, rhs: &'a Integer) -> BitAndRef<'a>
The method for the &
operator
impl<'a> From<BitAndRef<'a>> for Integer
[src]
impl<'a> Assign<BitAndRef<'a>> for Integer
[src]
impl BitOr<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the |
operator
fn bitor(self, op: Integer) -> Integer
The method for the |
operator
impl<'a> BitOr<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the |
operator
fn bitor(self, op: &'a Integer) -> Integer
The method for the |
operator
impl BitOrAssign<Integer> for Integer
[src]
fn bitor_assign(&mut self, op: Integer)
The method for the |=
operator
impl<'a> BitOrAssign<&'a Integer> for Integer
[src]
fn bitor_assign(&mut self, op: &'a Integer)
The method for the |=
operator
impl<'a> BitOr<&'a Integer> for &'a Integer
[src]
type Output = BitOrRef<'a>
The resulting type after applying the |
operator
fn bitor(self, rhs: &'a Integer) -> BitOrRef<'a>
The method for the |
operator
impl<'a> From<BitOrRef<'a>> for Integer
[src]
impl<'a> Assign<BitOrRef<'a>> for Integer
[src]
impl BitXor<Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the ^
operator
fn bitxor(self, op: Integer) -> Integer
The method for the ^
operator
impl<'a> BitXor<&'a Integer> for Integer
[src]
type Output = Integer
The resulting type after applying the ^
operator
fn bitxor(self, op: &'a Integer) -> Integer
The method for the ^
operator
impl BitXorAssign<Integer> for Integer
[src]
fn bitxor_assign(&mut self, op: Integer)
The method for the ^=
operator
impl<'a> BitXorAssign<&'a Integer> for Integer
[src]
fn bitxor_assign(&mut self, op: &'a Integer)
The method for the ^=
operator
impl<'a> BitXor<&'a Integer> for &'a Integer
[src]
type Output = BitXorRef<'a>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: &'a Integer) -> BitXorRef<'a>
The method for the ^
operator
impl<'a> From<BitXorRef<'a>> for Integer
[src]
impl<'a> Assign<BitXorRef<'a>> for Integer
[src]
impl Add<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, op: i32) -> Integer
The method for the +
operator
impl AddAssign<i32> for Integer
[src]
fn add_assign(&mut self, op: i32)
The method for the +=
operator
impl<'a> Add<i32> for &'a Integer
[src]
type Output = AddRefI32<'a>
The resulting type after applying the +
operator
fn add(self, op: i32) -> AddRefI32<'a>
The method for the +
operator
impl<'a> From<AddRefI32<'a>> for Integer
[src]
impl<'a> Assign<AddRefI32<'a>> for Integer
[src]
impl Sub<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, op: i32) -> Integer
The method for the -
operator
impl SubAssign<i32> for Integer
[src]
fn sub_assign(&mut self, op: i32)
The method for the -=
operator
impl<'a> Sub<i32> for &'a Integer
[src]
type Output = SubRefI32<'a>
The resulting type after applying the -
operator
fn sub(self, op: i32) -> SubRefI32<'a>
The method for the -
operator
impl<'a> From<SubRefI32<'a>> for Integer
[src]
impl<'a> Assign<SubRefI32<'a>> for Integer
[src]
impl SubFromAssign<i32> for Integer
[src]
fn sub_from_assign(&mut self, lhs: i32)
Peforms the subtraction. Read more
impl<'a> From<SubFromRefI32<'a>> for Integer
[src]
impl<'a> Assign<SubFromRefI32<'a>> for Integer
[src]
impl Mul<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the *
operator
fn mul(self, op: i32) -> Integer
The method for the *
operator
impl MulAssign<i32> for Integer
[src]
fn mul_assign(&mut self, op: i32)
The method for the *=
operator
impl<'a> Mul<i32> for &'a Integer
[src]
type Output = MulRefI32<'a>
The resulting type after applying the *
operator
fn mul(self, op: i32) -> MulRefI32<'a>
The method for the *
operator
impl<'a> From<MulRefI32<'a>> for Integer
[src]
impl<'a> Assign<MulRefI32<'a>> for Integer
[src]
impl Div<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the /
operator
fn div(self, op: i32) -> Integer
The method for the /
operator
impl DivAssign<i32> for Integer
[src]
fn div_assign(&mut self, op: i32)
The method for the /=
operator
impl<'a> Div<i32> for &'a Integer
[src]
type Output = DivRefI32<'a>
The resulting type after applying the /
operator
fn div(self, op: i32) -> DivRefI32<'a>
The method for the /
operator
impl<'a> From<DivRefI32<'a>> for Integer
[src]
impl<'a> Assign<DivRefI32<'a>> for Integer
[src]
impl DivFromAssign<i32> for Integer
[src]
fn div_from_assign(&mut self, lhs: i32)
Peforms the division. Read more
impl<'a> From<DivFromRefI32<'a>> for Integer
[src]
impl<'a> Assign<DivFromRefI32<'a>> for Integer
[src]
impl Rem<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the %
operator
fn rem(self, op: i32) -> Integer
The method for the %
operator
impl RemAssign<i32> for Integer
[src]
fn rem_assign(&mut self, op: i32)
The method for the %=
operator
impl<'a> Rem<i32> for &'a Integer
[src]
type Output = RemRefI32<'a>
The resulting type after applying the %
operator
fn rem(self, op: i32) -> RemRefI32<'a>
The method for the %
operator
impl<'a> From<RemRefI32<'a>> for Integer
[src]
impl<'a> Assign<RemRefI32<'a>> for Integer
[src]
impl RemFromAssign<i32> for Integer
[src]
fn rem_from_assign(&mut self, lhs: i32)
Peforms the remainder operation. Read more
impl<'a> From<RemFromRefI32<'a>> for Integer
[src]
impl<'a> Assign<RemFromRefI32<'a>> for Integer
[src]
impl Shl<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the <<
operator
fn shl(self, op: i32) -> Integer
The method for the <<
operator
impl ShlAssign<i32> for Integer
[src]
fn shl_assign(&mut self, op: i32)
The method for the <<=
operator
impl<'a> Shl<i32> for &'a Integer
[src]
type Output = ShlRefI32<'a>
The resulting type after applying the <<
operator
fn shl(self, op: i32) -> ShlRefI32<'a>
The method for the <<
operator
impl<'a> From<ShlRefI32<'a>> for Integer
[src]
impl<'a> Assign<ShlRefI32<'a>> for Integer
[src]
impl Shr<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the >>
operator
fn shr(self, op: i32) -> Integer
The method for the >>
operator
impl ShrAssign<i32> for Integer
[src]
fn shr_assign(&mut self, op: i32)
The method for the >>=
operator
impl<'a> Shr<i32> for &'a Integer
[src]
type Output = ShrRefI32<'a>
The resulting type after applying the >>
operator
fn shr(self, op: i32) -> ShrRefI32<'a>
The method for the >>
operator
impl<'a> From<ShrRefI32<'a>> for Integer
[src]
impl<'a> Assign<ShrRefI32<'a>> for Integer
[src]
impl BitAnd<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the &
operator
fn bitand(self, op: i32) -> Integer
The method for the &
operator
impl BitAndAssign<i32> for Integer
[src]
fn bitand_assign(&mut self, op: i32)
The method for the &=
operator
impl<'a> BitAnd<i32> for &'a Integer
[src]
type Output = BitAndRefI32<'a>
The resulting type after applying the &
operator
fn bitand(self, op: i32) -> BitAndRefI32<'a>
The method for the &
operator
impl<'a> From<BitAndRefI32<'a>> for Integer
[src]
impl<'a> Assign<BitAndRefI32<'a>> for Integer
[src]
impl BitOr<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the |
operator
fn bitor(self, op: i32) -> Integer
The method for the |
operator
impl BitOrAssign<i32> for Integer
[src]
fn bitor_assign(&mut self, op: i32)
The method for the |=
operator
impl<'a> BitOr<i32> for &'a Integer
[src]
type Output = BitOrRefI32<'a>
The resulting type after applying the |
operator
fn bitor(self, op: i32) -> BitOrRefI32<'a>
The method for the |
operator
impl<'a> From<BitOrRefI32<'a>> for Integer
[src]
impl<'a> Assign<BitOrRefI32<'a>> for Integer
[src]
impl BitXor<i32> for Integer
[src]
type Output = Integer
The resulting type after applying the ^
operator
fn bitxor(self, op: i32) -> Integer
The method for the ^
operator
impl BitXorAssign<i32> for Integer
[src]
fn bitxor_assign(&mut self, op: i32)
The method for the ^=
operator
impl<'a> BitXor<i32> for &'a Integer
[src]
type Output = BitXorRefI32<'a>
The resulting type after applying the ^
operator
fn bitxor(self, op: i32) -> BitXorRefI32<'a>
The method for the ^
operator
impl<'a> From<BitXorRefI32<'a>> for Integer
[src]
impl<'a> Assign<BitXorRefI32<'a>> for Integer
[src]
impl Add<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, op: u32) -> Integer
The method for the +
operator
impl AddAssign<u32> for Integer
[src]
fn add_assign(&mut self, op: u32)
The method for the +=
operator
impl<'a> Add<u32> for &'a Integer
[src]
type Output = AddRefU32<'a>
The resulting type after applying the +
operator
fn add(self, op: u32) -> AddRefU32<'a>
The method for the +
operator
impl<'a> From<AddRefU32<'a>> for Integer
[src]
impl<'a> Assign<AddRefU32<'a>> for Integer
[src]
impl Sub<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, op: u32) -> Integer
The method for the -
operator
impl SubAssign<u32> for Integer
[src]
fn sub_assign(&mut self, op: u32)
The method for the -=
operator
impl<'a> Sub<u32> for &'a Integer
[src]
type Output = SubRefU32<'a>
The resulting type after applying the -
operator
fn sub(self, op: u32) -> SubRefU32<'a>
The method for the -
operator
impl<'a> From<SubRefU32<'a>> for Integer
[src]
impl<'a> Assign<SubRefU32<'a>> for Integer
[src]
impl SubFromAssign<u32> for Integer
[src]
fn sub_from_assign(&mut self, lhs: u32)
Peforms the subtraction. Read more
impl<'a> From<SubFromRefU32<'a>> for Integer
[src]
impl<'a> Assign<SubFromRefU32<'a>> for Integer
[src]
impl Mul<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the *
operator
fn mul(self, op: u32) -> Integer
The method for the *
operator
impl MulAssign<u32> for Integer
[src]
fn mul_assign(&mut self, op: u32)
The method for the *=
operator
impl<'a> Mul<u32> for &'a Integer
[src]
type Output = MulRefU32<'a>
The resulting type after applying the *
operator
fn mul(self, op: u32) -> MulRefU32<'a>
The method for the *
operator
impl<'a> From<MulRefU32<'a>> for Integer
[src]
impl<'a> Assign<MulRefU32<'a>> for Integer
[src]
impl Div<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the /
operator
fn div(self, op: u32) -> Integer
The method for the /
operator
impl DivAssign<u32> for Integer
[src]
fn div_assign(&mut self, op: u32)
The method for the /=
operator
impl<'a> Div<u32> for &'a Integer
[src]
type Output = DivRefU32<'a>
The resulting type after applying the /
operator
fn div(self, op: u32) -> DivRefU32<'a>
The method for the /
operator
impl<'a> From<DivRefU32<'a>> for Integer
[src]
impl<'a> Assign<DivRefU32<'a>> for Integer
[src]
impl DivFromAssign<u32> for Integer
[src]
fn div_from_assign(&mut self, lhs: u32)
Peforms the division. Read more
impl<'a> From<DivFromRefU32<'a>> for Integer
[src]
impl<'a> Assign<DivFromRefU32<'a>> for Integer
[src]
impl Rem<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the %
operator
fn rem(self, op: u32) -> Integer
The method for the %
operator
impl RemAssign<u32> for Integer
[src]
fn rem_assign(&mut self, op: u32)
The method for the %=
operator
impl<'a> Rem<u32> for &'a Integer
[src]
type Output = RemRefU32<'a>
The resulting type after applying the %
operator
fn rem(self, op: u32) -> RemRefU32<'a>
The method for the %
operator
impl<'a> From<RemRefU32<'a>> for Integer
[src]
impl<'a> Assign<RemRefU32<'a>> for Integer
[src]
impl RemFromAssign<u32> for Integer
[src]
fn rem_from_assign(&mut self, lhs: u32)
Peforms the remainder operation. Read more
impl<'a> From<RemFromRefU32<'a>> for Integer
[src]
impl<'a> Assign<RemFromRefU32<'a>> for Integer
[src]
impl Shl<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the <<
operator
fn shl(self, op: u32) -> Integer
The method for the <<
operator
impl ShlAssign<u32> for Integer
[src]
fn shl_assign(&mut self, op: u32)
The method for the <<=
operator
impl<'a> Shl<u32> for &'a Integer
[src]
type Output = ShlRefU32<'a>
The resulting type after applying the <<
operator
fn shl(self, op: u32) -> ShlRefU32<'a>
The method for the <<
operator
impl<'a> From<ShlRefU32<'a>> for Integer
[src]
impl<'a> Assign<ShlRefU32<'a>> for Integer
[src]
impl Shr<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the >>
operator
fn shr(self, op: u32) -> Integer
The method for the >>
operator
impl ShrAssign<u32> for Integer
[src]
fn shr_assign(&mut self, op: u32)
The method for the >>=
operator
impl<'a> Shr<u32> for &'a Integer
[src]
type Output = ShrRefU32<'a>
The resulting type after applying the >>
operator
fn shr(self, op: u32) -> ShrRefU32<'a>
The method for the >>
operator
impl<'a> From<ShrRefU32<'a>> for Integer
[src]
impl<'a> Assign<ShrRefU32<'a>> for Integer
[src]
impl Pow<u32> for Integer
[src]
type Output = Integer
The resulting type after the power operation.
fn pow(self, op: u32) -> Integer
Performs the power operation. Read more
impl PowAssign<u32> for Integer
[src]
fn pow_assign(&mut self, op: u32)
Peforms the power operation. Read more
impl<'a> Pow<u32> for &'a Integer
[src]
type Output = PowRefU32<'a>
The resulting type after the power operation.
fn pow(self, op: u32) -> PowRefU32<'a>
Performs the power operation. Read more
impl<'a> From<PowRefU32<'a>> for Integer
[src]
impl<'a> Assign<PowRefU32<'a>> for Integer
[src]
impl BitAnd<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the &
operator
fn bitand(self, op: u32) -> Integer
The method for the &
operator
impl BitAndAssign<u32> for Integer
[src]
fn bitand_assign(&mut self, op: u32)
The method for the &=
operator
impl<'a> BitAnd<u32> for &'a Integer
[src]
type Output = BitAndRefU32<'a>
The resulting type after applying the &
operator
fn bitand(self, op: u32) -> BitAndRefU32<'a>
The method for the &
operator
impl<'a> From<BitAndRefU32<'a>> for Integer
[src]
impl<'a> Assign<BitAndRefU32<'a>> for Integer
[src]
impl BitOr<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the |
operator
fn bitor(self, op: u32) -> Integer
The method for the |
operator
impl BitOrAssign<u32> for Integer
[src]
fn bitor_assign(&mut self, op: u32)
The method for the |=
operator
impl<'a> BitOr<u32> for &'a Integer
[src]
type Output = BitOrRefU32<'a>
The resulting type after applying the |
operator
fn bitor(self, op: u32) -> BitOrRefU32<'a>
The method for the |
operator
impl<'a> From<BitOrRefU32<'a>> for Integer
[src]
impl<'a> Assign<BitOrRefU32<'a>> for Integer
[src]
impl BitXor<u32> for Integer
[src]
type Output = Integer
The resulting type after applying the ^
operator
fn bitxor(self, op: u32) -> Integer
The method for the ^
operator
impl BitXorAssign<u32> for Integer
[src]
fn bitxor_assign(&mut self, op: u32)
The method for the ^=
operator
impl<'a> BitXor<u32> for &'a Integer
[src]
type Output = BitXorRefU32<'a>
The resulting type after applying the ^
operator
fn bitxor(self, op: u32) -> BitXorRefU32<'a>
The method for the ^
operator
impl<'a> From<BitXorRefU32<'a>> for Integer
[src]
impl<'a> Assign<BitXorRefU32<'a>> for Integer
[src]
impl<'a> Add<MulRef<'a>> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, rhs: MulRef) -> Integer
Peforms multiplication and addition together.
Examples
use rug::Integer; let m1 = Integer::from(3); let m2 = Integer::from(7); let init = Integer::from(100); let acc = init + &m1 * &m2; assert_eq!(acc, 121);
impl<'a> AddAssign<MulRef<'a>> for Integer
[src]
fn add_assign(&mut self, rhs: MulRef)
Peforms multiplication and addition together.
Examples
use rug::Integer; let m1 = Integer::from(3); let m2 = Integer::from(7); let mut acc = Integer::from(100); acc += &m1 * &m2; assert_eq!(acc, 121);
impl<'a> Add<MulRefU32<'a>> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, rhs: MulRefU32) -> Integer
Peforms multiplication and addition together.
Examples
use rug::Integer; let m = Integer::from(3); let init = Integer::from(100); let acc = init + &m * 7u32; assert_eq!(acc, 121);
impl<'a> AddAssign<MulRefU32<'a>> for Integer
[src]
fn add_assign(&mut self, rhs: MulRefU32)
Peforms multiplication and addition together.
Examples
use rug::Integer; let m = Integer::from(3); let mut acc = Integer::from(100); acc += &m * 7u32; assert_eq!(acc, 121);
impl<'a> Add<MulRefI32<'a>> for Integer
[src]
type Output = Integer
The resulting type after applying the +
operator
fn add(self, rhs: MulRefI32) -> Integer
Peforms multiplication and addition together.
Examples
use rug::Integer; let m = Integer::from(3); let init = Integer::from(100); let acc = init + &m * -7i32; assert_eq!(acc, 79);
impl<'a> AddAssign<MulRefI32<'a>> for Integer
[src]
fn add_assign(&mut self, rhs: MulRefI32)
Peforms multiplication and addition together.
Examples
use rug::Integer; let m = Integer::from(3); let mut acc = Integer::from(100); acc += &m * -7i32; assert_eq!(acc, 79);
impl<'a> Sub<MulRef<'a>> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, rhs: MulRef) -> Integer
Peforms multiplication and subtraction together.
Examples
use rug::Integer; let m1 = Integer::from(3); let m2 = Integer::from(7); let init = Integer::from(100); let acc = init - &m1 * &m2; assert_eq!(acc, 79);
impl<'a> SubAssign<MulRef<'a>> for Integer
[src]
fn sub_assign(&mut self, rhs: MulRef)
Peforms multiplication and subtraction together.
Examples
use rug::Integer; let m1 = Integer::from(3); let m2 = Integer::from(7); let mut acc = Integer::from(100); acc -= &m1 * &m2; assert_eq!(acc, 79);
impl<'a> Sub<MulRefU32<'a>> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, rhs: MulRefU32) -> Integer
Peforms multiplication and subtraction together.
Examples
use rug::Integer; let m = Integer::from(3); let init = Integer::from(100); let acc = init - &m * 7u32; assert_eq!(acc, 79);
impl<'a> SubAssign<MulRefU32<'a>> for Integer
[src]
fn sub_assign(&mut self, rhs: MulRefU32)
Peforms multiplication and subtraction together.
Examples
use rug::Integer; let m = Integer::from(3); let mut acc = Integer::from(100); acc -= &m * 7u32; assert_eq!(acc, 79);
impl<'a> Sub<MulRefI32<'a>> for Integer
[src]
type Output = Integer
The resulting type after applying the -
operator
fn sub(self, rhs: MulRefI32) -> Integer
Peforms multiplication and subtraction together.
Examples
use rug::Integer; let m = Integer::from(3); let init = Integer::from(100); let acc = init - &m * -7i32; assert_eq!(acc, 121);
impl<'a> SubAssign<MulRefI32<'a>> for Integer
[src]
fn sub_assign(&mut self, rhs: MulRefI32)
Peforms multiplication and subtraction together.
Examples
use rug::Integer; let m = Integer::from(3); let mut acc = Integer::from(100); acc -= &m * -7i32; assert_eq!(acc, 121);
impl Eq for Integer
[src]
impl Ord for Integer
[src]
fn cmp(&self, other: &Integer) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl PartialEq for Integer
[src]
fn eq(&self, other: &Integer) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd for Integer
[src]
fn partial_cmp(&self, other: &Integer) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<i32> for Integer
[src]
fn eq(&self, other: &i32) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<i32> for Integer
[src]
fn partial_cmp(&self, other: &i32) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<i64> for Integer
[src]
fn eq(&self, other: &i64) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<i64> for Integer
[src]
fn partial_cmp(&self, other: &i64) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<u32> for Integer
[src]
fn eq(&self, other: &u32) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<u32> for Integer
[src]
fn partial_cmp(&self, other: &u32) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<u64> for Integer
[src]
fn eq(&self, other: &u64) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<u64> for Integer
[src]
fn partial_cmp(&self, other: &u64) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<f32> for Integer
[src]
fn eq(&self, other: &f32) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<f32> for Integer
[src]
fn partial_cmp(&self, other: &f32) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<f64> for Integer
[src]
fn eq(&self, other: &f64) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<f64> for Integer
[src]
fn partial_cmp(&self, other: &f64) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a> From<ValidInteger<'a>> for Integer
[src]
fn from(t: ValidInteger<'a>) -> Integer
Performs the conversion.
impl<'a> Assign<ValidInteger<'a>> for Integer
[src]
fn assign(&mut self, rhs: ValidInteger)
Peforms the assignement. Read more
impl Send for Integer
[src]
impl Sync for Integer
[src]
impl<'a> Assign<CeilRef<'a>> for Integer
[src]
impl<'a> Assign<FloorRef<'a>> for Integer
[src]
impl<'a> Assign<RoundRef<'a>> for Integer
[src]
impl<'a> Assign<TruncRef<'a>> for Integer
[src]
impl PartialEq<Rational> for Integer
[src]
fn eq(&self, other: &Rational) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<Rational> for Integer
[src]
fn partial_cmp(&self, other: &Rational) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a> Add<Float> for &'a Integer
[src]
type Output = Float
The resulting type after applying the +
operator
fn add(self, rhs: Float) -> Float
The method for the +
operator
impl<'a> AddRound<Float> for &'a Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the addition.
fn add_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the addition. Read more
impl Add<Float> for Integer
[src]
type Output = Float
The resulting type after applying the +
operator
fn add(self, rhs: Float) -> Float
The method for the +
operator
impl AddRound<Float> for Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the addition.
fn add_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the addition. Read more
impl<'a> Add<&'a Float> for &'a Integer
[src]
type Output = AddRefInteger<'a>
The resulting type after applying the +
operator
fn add(self, rhs: &'a Float) -> AddRefInteger<'a>
The method for the +
operator
impl<'a> Add<&'a Float> for Integer
[src]
type Output = AddRefIntegerOwn<'a>
The resulting type after applying the +
operator
fn add(self, rhs: &'a Float) -> AddRefIntegerOwn<'a>
The method for the +
operator
impl<'a> Sub<Float> for &'a Integer
[src]
type Output = Float
The resulting type after applying the -
operator
fn sub(self, rhs: Float) -> Float
The method for the -
operator
impl<'a> SubRound<Float> for &'a Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the subtraction.
fn sub_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the subtraction. Read more
impl Sub<Float> for Integer
[src]
type Output = Float
The resulting type after applying the -
operator
fn sub(self, rhs: Float) -> Float
The method for the -
operator
impl SubRound<Float> for Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the subtraction.
fn sub_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the subtraction. Read more
impl<'a> Sub<&'a Float> for &'a Integer
[src]
type Output = SubRefIntegerOwn<'a>
The resulting type after applying the -
operator
fn sub(self, rhs: &'a Float) -> SubRefIntegerOwn<'a>
The method for the -
operator
impl<'a> Sub<&'a Float> for Integer
[src]
type Output = SubFromRefIntegerOwn<'a>
The resulting type after applying the -
operator
fn sub(self, rhs: &'a Float) -> SubFromRefIntegerOwn<'a>
The method for the -
operator
impl<'a> Mul<Float> for &'a Integer
[src]
type Output = Float
The resulting type after applying the *
operator
fn mul(self, rhs: Float) -> Float
The method for the *
operator
impl<'a> MulRound<Float> for &'a Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the multiplication.
fn mul_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the multiplication. Read more
impl Mul<Float> for Integer
[src]
type Output = Float
The resulting type after applying the *
operator
fn mul(self, rhs: Float) -> Float
The method for the *
operator
impl MulRound<Float> for Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the multiplication.
fn mul_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the multiplication. Read more
impl<'a> Mul<&'a Float> for &'a Integer
[src]
type Output = MulRefInteger<'a>
The resulting type after applying the *
operator
fn mul(self, rhs: &'a Float) -> MulRefInteger<'a>
The method for the *
operator
impl<'a> Mul<&'a Float> for Integer
[src]
type Output = MulRefIntegerOwn<'a>
The resulting type after applying the *
operator
fn mul(self, rhs: &'a Float) -> MulRefIntegerOwn<'a>
The method for the *
operator
impl<'a> Div<Float> for &'a Integer
[src]
type Output = Float
The resulting type after applying the /
operator
fn div(self, rhs: Float) -> Float
The method for the /
operator
impl<'a> DivRound<Float> for &'a Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the division.
fn div_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the division. Read more
impl Div<Float> for Integer
[src]
type Output = Float
The resulting type after applying the /
operator
fn div(self, rhs: Float) -> Float
The method for the /
operator
impl DivRound<Float> for Integer
[src]
type Round = Round
The rounding method.
type Ordering = Ordering
The direction from rounding.
type Output = Float
The resulting type after the division.
fn div_round(self, rhs: Float, round: Round) -> (Float, Ordering)
Performs the division. Read more
impl<'a> Div<&'a Float> for &'a Integer
[src]
type Output = DivRefIntegerOwn<'a>
The resulting type after applying the /
operator
fn div(self, rhs: &'a Float) -> DivRefIntegerOwn<'a>
The method for the /
operator
impl<'a> Div<&'a Float> for Integer
[src]
type Output = DivFromRefIntegerOwn<'a>
The resulting type after applying the /
operator
fn div(self, rhs: &'a Float) -> DivFromRefIntegerOwn<'a>
The method for the /
operator
impl PartialEq<Float> for Integer
[src]
fn eq(&self, other: &Float) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl PartialOrd<Float> for Integer
[src]
fn partial_cmp(&self, other: &Float) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more