about summary refs log tree commit diff
path: root/src/libstd/num/bigint.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-04-29 13:39:37 -0700
committerbors <bors@rust-lang.org>2013-04-29 13:39:37 -0700
commitdbcc3fe63a71d92d194d99dfd5e73fb62d09e79a (patch)
tree642f815ad0d6a4043531bb0bfa521e459febaf50 /src/libstd/num/bigint.rs
parent76ec35ae743ee299484a48b233bc64cf3779097d (diff)
parent500078e147e1e5f5cf9bd57459ebbdda652d97ed (diff)
auto merge of #6110 : bjz/rust/numeric-traits, r=pcwalton
As discussed on issue #4819, I have created four new traits: `Algebraic`, `Trigonometric`, `Exponential` and `Hyperbolic`, and moved the appropriate methods into them from `Real`.

~~~rust
pub trait Algebraic {
    fn pow(&self, n: Self) -> Self;
    fn sqrt(&self) -> Self;
    fn rsqrt(&self) -> Self;
    fn cbrt(&self) -> Self;
    fn hypot(&self, other: Self) -> Self;
}

pub trait Trigonometric {
    fn sin(&self) -> Self;
    fn cos(&self) -> Self;
    fn tan(&self) -> Self;
    fn asin(&self) -> Self;
    fn acos(&self) -> Self;
    fn atan(&self) -> Self;
    fn atan2(&self, other: Self) -> Self;
}

pub trait Exponential {
    fn exp(&self) -> Self;
    fn exp2(&self) -> Self;
    fn expm1(&self) -> Self;
    fn log(&self) -> Self;
    fn log2(&self) -> Self;
    fn log10(&self) -> Self;
}

pub trait Hyperbolic: Exponential {
    fn sinh(&self) -> Self;
    fn cosh(&self) -> Self;
    fn tanh(&self) -> Self;
}
~~~

There was some discussion over whether we should shorten the names, for example `Trig` and `Exp`. No abbreviations have been agreed on yet, but this could be considered in the future.

Additionally, `Integer::divisible_by` has been renamed to `Integer::is_multiple_of`.
Diffstat (limited to 'src/libstd/num/bigint.rs')
-rw-r--r--src/libstd/num/bigint.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/num/bigint.rs b/src/libstd/num/bigint.rs
index 3ea94eababb..e97b3b5eeec 100644
--- a/src/libstd/num/bigint.rs
+++ b/src/libstd/num/bigint.rs
@@ -428,7 +428,7 @@ impl Integer for BigUint {
 
     /// Returns `true` if the number can be divided by `other` without leaving a remainder
     #[inline(always)]
-    fn divisible_by(&self, other: &BigUint) -> bool { (*self % *other).is_zero() }
+    fn is_multiple_of(&self, other: &BigUint) -> bool { (*self % *other).is_zero() }
 
     /// Returns `true` if the number is divisible by `2`
     #[inline(always)]
@@ -973,7 +973,7 @@ impl Integer for BigInt {
 
     /// Returns `true` if the number can be divided by `other` without leaving a remainder
     #[inline(always)]
-    fn divisible_by(&self, other: &BigInt) -> bool { self.data.divisible_by(&other.data) }
+    fn is_multiple_of(&self, other: &BigInt) -> bool { self.data.is_multiple_of(&other.data) }
 
     /// Returns `true` if the number is divisible by `2`
     #[inline(always)]