#![feature(slicing_syntax)]
#![cfg_attr(test, deny(warnings))]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/num/",
html_playground_url = "http://play.rust-lang.org/")]
#![allow(unstable)]
extern crate "rustc-serialize" as rustc_serialize;
pub use bigint::{BigInt, BigUint};
pub use rational::{Rational, BigRational};
pub use complex::Complex;
pub use integer::Integer;
pub use iter::{range, range_inclusive, range_step, range_step_inclusive};
pub use traits::{Num, Zero, One, Signed, Unsigned, Bounded,
Saturating, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
#[cfg(test)] use std::hash;
use std::ops::{Mul};
pub mod bigint;
pub mod complex;
pub mod integer;
pub mod iter;
pub mod traits;
pub mod rational;
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }
#[inline(always)] pub fn one<T: One>() -> T { One::one() }
#[inline(always)]
pub fn abs<T: Signed>(value: T) -> T {
value.abs()
}
#[inline(always)]
pub fn abs_sub<T: Signed>(x: T, y: T) -> T {
x.abs_sub(&y)
}
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
#[inline]
pub fn pow<T: Clone + One + Mul<T, Output = T>>(mut base: T, mut exp: usize) -> T {
if exp == 1 { base }
else {
let mut acc = one::<T>();
while exp > 0 {
if (exp & 1) == 1 {
acc = acc * base.clone();
}
base = base.clone() * base;
exp = exp >> 1;
}
acc
}
}
#[cfg(test)]
fn hash<T: hash::Hash<hash::SipHasher>>(x: &T) -> u64 {
hash::hash::<_, hash::SipHasher>(x)
}