core: add abs to num.

This commit is contained in:
Graydon Hoare 2013-01-15 17:30:16 -08:00
parent 389125aeb8
commit 73280b0472

View file

@ -39,6 +39,10 @@ pub trait One {
static pure fn one() -> Self;
}
pub pure fn abs<T: cmp::Ord Num Zero>(v: T) -> T {
if v < Zero::zero() { v.neg() } else { v }
}
pub trait Round {
pure fn round(&self, mode: RoundMode) -> Self;