Trait FloatCore
trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy
Generic trait for floating point numbers that works with no_std.
This trait implements a subset of the Float trait.
Required Methods
fn infinity() -> SelfReturns positive infinity.
Examples
use FloatCore; use ; check; check;fn neg_infinity() -> SelfReturns negative infinity.
Examples
use FloatCore; use ; check; check;fn nan() -> SelfReturns NaN.
Examples
use FloatCore; ; ;fn neg_zero() -> SelfReturns
-0.0.Examples
use FloatCore; use ; check; check;fn min_value() -> SelfReturns the smallest finite value that this type can represent.
Examples
use FloatCore; use ; check; check;fn min_positive_value() -> SelfReturns the smallest positive, normalized value that this type can represent.
Examples
use FloatCore; use ; check; check;fn epsilon() -> SelfReturns epsilon, a small positive value.
Examples
use FloatCore; use ; check; check;fn max_value() -> SelfReturns the largest finite value that this type can represent.
Examples
use FloatCore; use ; check; check;fn classify(self: Self) -> FpCategoryReturns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.
Examples
use FloatCore; use ; use FpCategory; check; check; check; check; check; check;fn to_degrees(self: Self) -> SelfConverts to degrees, assuming the number is in radians.
Examples
use FloatCore; use ; check; check; check; check;fn to_radians(self: Self) -> SelfConverts to radians, assuming the number is in degrees.
Examples
use FloatCore; use ; check; check; check; check;fn integer_decode(self: Self) -> (u64, i16, i8)Returns the mantissa, base 2 exponent, and sign as integers, respectively. The original number can be recovered by
sign * mantissa * 2 ^ exponent.Examples
use FloatCore; use ; check; check; check; check;
Provided Methods
fn is_nan(self: Self) -> boolReturns
trueif the number is NaN.Examples
use FloatCore; use ; check; check; check; check;fn is_infinite(self: Self) -> boolReturns
trueif the number is infinite.Examples
use FloatCore; use ; check; check; check; check; check; check;fn is_finite(self: Self) -> boolReturns
trueif the number is neither infinite or NaN.Examples
use FloatCore; use ; check; check; check; check; check;fn is_normal(self: Self) -> boolReturns
trueif the number is neither zero, infinite, subnormal or NaN.Examples
use FloatCore; use ; check; check; check; check; check;fn is_subnormal(self: Self) -> boolReturns
trueif the number is subnormal.use FloatCore; use f64; let min = f64MIN_POSITIVE; // 2.2250738585072014e-308_f64 let max = f64MAX; let lower_than_min = 1.0e-308_f64; let zero = 0.0_f64; assert!; assert!; assert!; assert!; assert!; // Values between `0` and `min` are Subnormal. assert!;fn floor(self: Self) -> SelfReturns the largest integer less than or equal to a number.
Examples
use FloatCore; use ; check; check; check; check; check; check; check; check; check;fn ceil(self: Self) -> SelfReturns the smallest integer greater than or equal to a number.
Examples
use FloatCore; use ; check; check; check; check; check; check; check; check; check;fn round(self: Self) -> SelfReturns the nearest integer to a number. Round half-way cases away from
0.0.Examples
use FloatCore; use ; check; check; check; check; check; check; check; check;fn trunc(self: Self) -> SelfReturn the integer part of a number.
Examples
use FloatCore; use ; check; check; check; check; check; check; check; check; check;fn fract(self: Self) -> SelfReturns the fractional part of a number.
Examples
use FloatCore; use ; check; check; check; check; check; check; check; check; check;fn abs(self: Self) -> SelfComputes the absolute value of
self. ReturnsFloatCore::nan()if the number isFloatCore::nan().Examples
use FloatCore; use ; check; check; check; check; check; check;fn signum(self: Self) -> SelfReturns a number that represents the sign of
self.1.0if the number is positive,+0.0orFloatCore::infinity()-1.0if the number is negative,-0.0orFloatCore::neg_infinity()FloatCore::nan()if the number isFloatCore::nan()
Examples
use FloatCore; use ; check; check; check; check; check; check;fn is_sign_positive(self: Self) -> boolReturns
trueifselfis positive, including+0.0andFloatCore::infinity(), andFloatCore::nan().Examples
use FloatCore; use ; check; check; check; check; check; check; check; check;fn is_sign_negative(self: Self) -> boolReturns
trueifselfis negative, including-0.0andFloatCore::neg_infinity(), and-FloatCore::nan().Examples
use FloatCore; use ; check; check; check; check; check; check; check; check;fn min(self: Self, other: Self) -> SelfReturns the minimum of the two numbers.
If one of the arguments is NaN, then the other argument is returned.
Examples
use FloatCore; use ; check; check; check; check;fn max(self: Self, other: Self) -> SelfReturns the maximum of the two numbers.
If one of the arguments is NaN, then the other argument is returned.
Examples
use FloatCore; use ; check; check; check; check;fn clamp(self: Self, min: Self, max: Self) -> SelfA value bounded by a minimum and a maximum
If input is less than min then this returns min. If input is greater than max then this returns max. Otherwise this returns input.
Panics in debug mode if
!(min <= max).Examples
use FloatCore; check; check; check; check; check; check;fn recip(self: Self) -> SelfReturns the reciprocal (multiplicative inverse) of the number.
Examples
use FloatCore; use ; check; check; check; check;fn powi(self: Self, exp: i32) -> SelfRaise a number to an integer power.
Using this function is generally faster than using
powfExamples
use FloatCore; check; check; check; check; check;
Implementors
impl FloatCore for f32impl FloatCore for f64