diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/num/f32.rs | 11 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 12 | ||||
| -rw-r--r-- | src/libstd/num/mod.rs | 3 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index a686edef99e..fb56444d265 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -9,6 +9,7 @@ // except according to those terms. //! Operations and constants for 32-bits floats (`f32` type) + #[allow(missing_doc)]; use prelude::*; @@ -312,6 +313,16 @@ impl Primitive for f32 {} impl Float for f32 { #[inline] + fn max(self, other: f32) -> f32 { + unsafe { cmath::c_float::fmax(self, other) } + } + + #[inline] + fn min(self, other: f32) -> f32 { + unsafe { cmath::c_float::fmin(self, other) } + } + + #[inline] fn nan() -> f32 { 0.0 / 0.0 } #[inline] diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 026bd651e0e..7889041659a 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -23,8 +23,6 @@ use num::{Zero, One, Bounded, strconv}; use num; use intrinsics; -pub use cmp::{min, max}; - macro_rules! delegate( ( $( @@ -314,6 +312,16 @@ impl Primitive for f64 {} impl Float for f64 { #[inline] + fn max(self, other: f64) -> f64 { + unsafe { cmath::c_double::fmax(self, other) } + } + + #[inline] + fn min(self, other: f64) -> f64 { + unsafe { cmath::c_double::fmin(self, other) } + } + + #[inline] fn nan() -> f64 { 0.0 / 0.0 } #[inline] diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 2051eeef60c..2f377a52ef8 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -313,6 +313,9 @@ pub enum FPCategory { pub trait Float: Signed + Round + Primitive { + fn max(self, other: Self) -> Self; + fn min(self, other: Self) -> Self; + // FIXME (#5527): These should be associated constants fn nan() -> Self; fn infinity() -> Self; |
