Update float.rs

This commit is contained in:
YakoYakoYokuYoku 2019-02-14 21:56:50 -03:00 committed by Y4
parent dcf51dd9a0
commit 66bd294256
3 changed files with 1 additions and 57 deletions

View File

@ -1905,9 +1905,6 @@ pub trait CommonFloat where Self: Num + Copy + NumCast + Neg<Output = Self> {
/// Take the reciprocal (inverse) of a number, `1/x`.
fn recip(self) -> Self;
/// Raise a number to a floating point power.
fn powf(self, n: Self) -> Self;
/// Takes self to the power of a.
///
/// Returns NaN if self is negative.
@ -2078,7 +2075,6 @@ macro_rules! cfloat_impl {
Float::is_nan(self) -> bool;
Float::mul_add(self, a: Self, b: Self) -> Self;
Float::recip(self) -> Self;
Float::powf(self, n: Self) -> Self;
Float::sqrt(self) -> Self;
Float::exp(self) -> Self;
Float::exp2(self) -> Self;

View File

@ -29,6 +29,7 @@ pub use bounds::Bounded;
#[cfg(feature = "std")]
pub use float::Float;
pub use float::FloatConst;
pub use float::CommonFloat;
// pub use real::{FloatCore, Real}; // NOTE: Don't do this, it breaks `use num_traits::*;`.
pub use cast::{cast, AsPrimitive, FromPrimitive, NumCast, ToPrimitive};
pub use identities::{one, zero, One, Zero};

View File

@ -13,7 +13,6 @@ use {Float, Num, NumCast};
///
/// This trait is only available with the `std` feature.
pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
type Typo;
/// Returns the smallest finite value that this type can represent.
///
/// ```
@ -776,61 +775,9 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// assert!(abs_difference < 1.0e-10);
/// ```
fn atanh(self) -> Self;
/// Returns the real part of the float.
///
/// ```
/// use num_traits::Float;
///
/// let n = 0.5f64;
///
/// assert!(n.real() > 0.4f64);
/// ```
fn real(self) -> Self;
/// Returns the imaginary part of the float which equals to zero.
///
/// ```
/// use num_traits::Float;
///
/// let n = 2.7f64;
///
/// assert!(n.imag() == 0.0f64);
/// ```
fn imag(self) -> Self;
/// Computes the argument of the float.Float
///
/// ```
/// use num_traits::Float;
///
/// let n = 0.8f32;
///
/// assert_eq!(n.arg(), 0.0f32);
/// ```
fn arg(self) -> Self;
}
impl<T: Float + PartialOrd> Real for T {
type Typo = T;
#[inline]
fn real(self) -> T {
self
}
#[inline]
fn imag(self) -> T {
T::neg_zero()
}
#[inline]
fn arg(self) -> Self::Typo {
if self >= T::from(0).unwrap() {
T::from(0).unwrap()
} else {
T::from(3.14159265358979323846264338327950288_f64).unwrap()
}
}
forward! {
Float::min_value() -> Self;
Float::min_positive_value() -> Self;