#![doc(html_logo_url = "http://rust-num.github.io/num/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://rust-num.github.io/num/favicon.ico",
html_root_url = "http://rust-num.github.io/num/",
html_playground_url = "http://play.rust-lang.org/")]
#[cfg(feature = "rustc-serialize")]
extern crate rustc_serialize;
#[cfg(feature = "rand")]
extern crate rand;
#[cfg(feature = "bigint")]
pub use bigint::{BigInt, BigUint};
#[cfg(feature = "rational")]
pub use rational::Rational;
#[cfg(all(feature = "rational", feature="bigint"))]
pub use rational::BigRational;
#[cfg(feature = "complex")]
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,
PrimInt, Float, ToPrimitive, FromPrimitive, NumCast, cast};
#[cfg(test)] use std::hash;
use std::ops::{Mul};
#[cfg(feature = "bigint")]
pub mod bigint;
pub mod complex;
pub mod integer;
pub mod iter;
pub mod traits;
#[cfg(feature = "rational")]
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();
}
if exp > 1 {
base = base.clone() * base;
}
exp = exp >> 1;
}
acc
}
}
#[cfg(test)]
fn hash<T: hash::Hash>(x: &T) -> u64 {
use std::hash::Hasher;
let mut hasher = hash::SipHasher::new();
x.hash(&mut hasher);
hasher.finish()
}