Primitive Type f32 [-] [+]

Operations and constants for 32-bits floats (f32 type)

Trait Implementations

impl Float for f32

fn nan() -> f32

fn infinity() -> f32

fn neg_infinity() -> f32

fn zero() -> f32

fn neg_zero() -> f32

fn one() -> f32

fn is_nan(self) -> bool

Returns true if the number is NaN.

fn is_infinite(self) -> bool

Returns true if the number is infinite.

fn is_finite(self) -> bool

Returns true if the number is neither infinite or NaN.

fn is_normal(self) -> bool

Returns true if the number is neither zero, infinite, subnormal or NaN.

fn classify(self) -> FpCategory

Returns 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.

fn mantissa_digits(Option<f32>) -> usize

fn digits(Option<f32>) -> usize

fn epsilon() -> f32

fn min_exp(Option<f32>) -> isize

fn max_exp(Option<f32>) -> isize

fn min_10_exp(Option<f32>) -> isize

fn max_10_exp(Option<f32>) -> isize

fn min_value() -> f32

fn min_pos_value(Option<f32>) -> f32

fn max_value() -> f32

fn integer_decode(self) -> (u64, i16, i8)

Returns the mantissa, exponent and sign as integers.

fn floor(self) -> f32

Rounds towards minus infinity.

fn ceil(self) -> f32

Rounds towards plus infinity.

fn round(self) -> f32

Rounds to nearest integer. Rounds half-way cases away from zero.

fn trunc(self) -> f32

Returns the integer part of the number (rounds towards zero).

fn fract(self) -> f32

The fractional part of the number, satisfying:

fn main() { use core::num::Float; let x = 1.65f32; assert!(x == x.trunc() + x.fract()) }
use core::num::Float;

let x = 1.65f32;
assert!(x == x.trunc() + x.fract())

fn abs(self) -> f32

Computes the absolute value of self. Returns Float::nan() if the number is Float::nan().

fn signum(self) -> f32

Returns a number that represents the sign of self.

  • 1.0 if the number is positive, +0.0 or Float::infinity()
  • -1.0 if the number is negative, -0.0 or Float::neg_infinity()
  • Float::nan() if the number is Float::nan()

fn is_positive(self) -> bool

Returns true if self is positive, including +0.0 and Float::infinity().

fn is_negative(self) -> bool

Returns true if self is negative, including -0.0 and Float::neg_infinity().

fn mul_add(self, a: f32, b: f32) -> f32

Fused multiply-add. Computes (self * a) + b with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add.

fn recip(self) -> f32

Returns the reciprocal (multiplicative inverse) of the number.

fn powi(self, n: i32) -> f32

fn powf(self, n: f32) -> f32

fn sqrt(self) -> f32

fn rsqrt(self) -> f32

fn exp(self) -> f32

Returns the exponential of the number.

fn exp2(self) -> f32

Returns 2 raised to the power of the number.

fn ln(self) -> f32

Returns the natural logarithm of the number.

fn log(self, base: f32) -> f32

Returns the logarithm of the number with respect to an arbitrary base.

fn log2(self) -> f32

Returns the base 2 logarithm of the number.

fn log10(self) -> f32

Returns the base 10 logarithm of the number.

fn to_degrees(self) -> f32

Converts to degrees, assuming the number is in radians.

fn to_radians(self) -> f32

Converts to radians, assuming the number is in degrees.

impl ToPrimitive for f32

fn to_int(&self) -> Option<isize>

fn to_i8(&self) -> Option<i8>

fn to_i16(&self) -> Option<i16>

fn to_i32(&self) -> Option<i32>

fn to_i64(&self) -> Option<i64>

fn to_uint(&self) -> Option<usize>

fn to_u8(&self) -> Option<u8>

fn to_u16(&self) -> Option<u16>

fn to_u32(&self) -> Option<u32>

fn to_u64(&self) -> Option<u64>

fn to_f32(&self) -> Option<f32>

fn to_f64(&self) -> Option<f64>

fn to_int(&self) -> Option<isize>

fn to_i8(&self) -> Option<i8>

fn to_i16(&self) -> Option<i16>

fn to_i32(&self) -> Option<i32>

fn to_uint(&self) -> Option<usize>

fn to_u8(&self) -> Option<u8>

fn to_u16(&self) -> Option<u16>

fn to_u32(&self) -> Option<u32>

fn to_f32(&self) -> Option<f32>

fn to_f64(&self) -> Option<f64>

impl FromPrimitive for f32

fn from_int(n: isize) -> Option<f32>

fn from_i8(n: i8) -> Option<f32>

fn from_i16(n: i16) -> Option<f32>

fn from_i32(n: i32) -> Option<f32>

fn from_i64(n: i64) -> Option<f32>

fn from_uint(n: usize) -> Option<f32>

fn from_u8(n: u8) -> Option<f32>

fn from_u16(n: u16) -> Option<f32>

fn from_u32(n: u32) -> Option<f32>

fn from_u64(n: u64) -> Option<f32>

fn from_f32(n: f32) -> Option<f32>

fn from_f64(n: f64) -> Option<f32>

fn from_int(isize) -> Option<f32>

fn from_i8(i8) -> Option<f32>

fn from_i16(i16) -> Option<f32>

fn from_i32(i32) -> Option<f32>

fn from_uint(usize) -> Option<f32>

fn from_u8(u8) -> Option<f32>

fn from_u16(u16) -> Option<f32>

fn from_u32(u32) -> Option<f32>

fn from_f32(f32) -> Option<f32>

fn from_f64(f64) -> Option<f32>

impl NumCast for f32

fn from<N>(n: N) -> Option<f32> where N: ToPrimitive

impl FromStr for f32

type Err = ParseFloatError

fn from_str(src: &str) -> Result<f32, ParseFloatError>

Convert a string in base 10 to a float. Accepts an optional decimal exponent.

This function accepts strings such as

  • '3.14'
  • '+3.14', equivalent to '3.14'
  • '-3.14'
  • '2.5E10', or equivalently, '2.5e10'
  • '2.5E-10'
  • '.' (understood as 0)
  • '5.'
  • '.5', or, equivalently, '0.5'
  • '+inf', 'inf', '-inf', 'NaN'

Leading and trailing whitespace represent an error.

Arguments

  • src - A string

Return value

None if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by src.

impl FromStrRadix for f32

type Err = ParseFloatError

fn from_str_radix(src: &str, radix: u32) -> Result<f32, ParseFloatError>

Convert a string in a given base to a float.

Due to possible conflicts, this function does not accept the special values inf, -inf, +inf and NaN, nor does it recognize exponents of any kind.

Leading and trailing whitespace represent an error.

Arguments

  • src - A string
  • radix - The base to use. Must lie in the range [2 .. 36]

Return value

None if the string did not represent a valid number. Otherwise, Some(n) where n is the floating-point number represented by src.

impl Add<f32> for f32

type Output = f32

fn add(self, other: f32) -> f32

impl<'a> Add<f32> for &'a f32

type Output = <f32 as Add<f32>>::Output

fn add(self, other: f32) -> <f32 as Add<f32>>::Output

impl<'a> Add<&'a f32> for f32

type Output = <f32 as Add<f32>>::Output

fn add(self, other: &'a f32) -> <f32 as Add<f32>>::Output

impl<'a, 'b> Add<&'a f32> for &'b f32

type Output = <f32 as Add<f32>>::Output

fn add(self, other: &'a f32) -> <f32 as Add<f32>>::Output

impl Sub<f32> for f32

type Output = f32

fn sub(self, other: f32) -> f32

impl<'a> Sub<f32> for &'a f32

type Output = <f32 as Sub<f32>>::Output

fn sub(self, other: f32) -> <f32 as Sub<f32>>::Output

impl<'a> Sub<&'a f32> for f32

type Output = <f32 as Sub<f32>>::Output

fn sub(self, other: &'a f32) -> <f32 as Sub<f32>>::Output

impl<'a, 'b> Sub<&'a f32> for &'b f32

type Output = <f32 as Sub<f32>>::Output

fn sub(self, other: &'a f32) -> <f32 as Sub<f32>>::Output

impl Mul<f32> for f32

type Output = f32

fn mul(self, other: f32) -> f32

impl<'a> Mul<f32> for &'a f32

type Output = <f32 as Mul<f32>>::Output

fn mul(self, other: f32) -> <f32 as Mul<f32>>::Output

impl<'a> Mul<&'a f32> for f32

type Output = <f32 as Mul<f32>>::Output

fn mul(self, other: &'a f32) -> <f32 as Mul<f32>>::Output

impl<'a, 'b> Mul<&'a f32> for &'b f32

type Output = <f32 as Mul<f32>>::Output

fn mul(self, other: &'a f32) -> <f32 as Mul<f32>>::Output

impl Div<f32> for f32

type Output = f32

fn div(self, other: f32) -> f32

impl<'a> Div<f32> for &'a f32

type Output = <f32 as Div<f32>>::Output

fn div(self, other: f32) -> <f32 as Div<f32>>::Output

impl<'a> Div<&'a f32> for f32

type Output = <f32 as Div<f32>>::Output

fn div(self, other: &'a f32) -> <f32 as Div<f32>>::Output

impl<'a, 'b> Div<&'a f32> for &'b f32

type Output = <f32 as Div<f32>>::Output

fn div(self, other: &'a f32) -> <f32 as Div<f32>>::Output

impl Rem<f32> for f32

type Output = f32

fn rem(self, other: f32) -> f32

impl<'a> Rem<f32> for &'a f32

type Output = <f32 as Rem<f32>>::Output

fn rem(self, other: f32) -> <f32 as Rem<f32>>::Output

impl<'a> Rem<&'a f32> for f32

type Output = <f32 as Rem<f32>>::Output

fn rem(self, other: &'a f32) -> <f32 as Rem<f32>>::Output

impl<'a, 'b> Rem<&'a f32> for &'b f32

type Output = <f32 as Rem<f32>>::Output

fn rem(self, other: &'a f32) -> <f32 as Rem<f32>>::Output

impl Neg for f32

type Output = f32

fn neg(self) -> f32

impl<'a> Neg for &'a f32

type Output = <f32 as Neg>::Output

fn neg(self) -> <f32 as Neg>::Output

impl PartialEq<f32> for f32

fn eq(&self, other: &f32) -> bool

fn ne(&self, other: &f32) -> bool

fn ne(&self, &f32) -> bool

impl PartialOrd<f32> for f32

fn partial_cmp(&self, other: &f32) -> Option<Ordering>

fn lt(&self, other: &f32) -> bool

fn le(&self, other: &f32) -> bool

fn ge(&self, other: &f32) -> bool

fn gt(&self, other: &f32) -> bool

fn lt(&self, &f32) -> bool

fn le(&self, &f32) -> bool

fn gt(&self, &f32) -> bool

fn ge(&self, &f32) -> bool

impl Clone for f32

fn clone(&self) -> f32

Return a deep copy of the value.

fn clone_from(&mut self, &f32)

impl Default for f32

fn default() -> f32

impl Debug for f32

fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>

impl Display for f32

fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>

impl LowerExp for f32

fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>

impl UpperExp for f32

fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>

impl Float for f32

fn nan() -> f32

fn infinity() -> f32

fn neg_infinity() -> f32

fn zero() -> f32

fn neg_zero() -> f32

fn one() -> f32

fn mantissa_digits(unused_self: Option<f32>) -> usize

fn digits(unused_self: Option<f32>) -> usize

fn epsilon() -> f32

fn min_exp(unused_self: Option<f32>) -> isize

fn max_exp(unused_self: Option<f32>) -> isize

fn min_10_exp(unused_self: Option<f32>) -> isize

fn max_10_exp(unused_self: Option<f32>) -> isize

fn min_value() -> f32

fn min_pos_value(unused_self: Option<f32>) -> f32

fn max_value() -> f32

fn is_nan(self) -> bool

fn is_infinite(self) -> bool

fn is_finite(self) -> bool

fn is_normal(self) -> bool

fn classify(self) -> FpCategory

fn integer_decode(self) -> (u64, i16, i8)

fn floor(self) -> f32

fn ceil(self) -> f32

fn round(self) -> f32

fn trunc(self) -> f32

fn fract(self) -> f32

fn abs(self) -> f32

fn signum(self) -> f32

fn is_positive(self) -> bool

fn is_negative(self) -> bool

fn mul_add(self, a: f32, b: f32) -> f32

fn recip(self) -> f32

fn powi(self, n: i32) -> f32

fn powf(self, n: f32) -> f32

fn sqrt(self) -> f32

fn rsqrt(self) -> f32

fn exp(self) -> f32

fn exp2(self) -> f32

fn ln(self) -> f32

fn log(self, base: f32) -> f32

fn log2(self) -> f32

fn log10(self) -> f32

fn to_degrees(self) -> f32

fn to_radians(self) -> f32

fn ldexp(x: f32, exp: isize) -> f32

Constructs a floating point number by multiplying x by 2 raised to the power of exp

fn frexp(self) -> (f32, isize)

Breaks the number into a normalized fraction and a base-2 exponent, satisfying:

  • self = x * pow(2, exp)
  • 0.5 <= abs(x) < 1.0

fn next_after(self, other: f32) -> f32

Returns the next representable floating-point value in the direction of other.

fn max(self, other: f32) -> f32

fn min(self, other: f32) -> f32

fn abs_sub(self, other: f32) -> f32

fn cbrt(self) -> f32

fn hypot(self, other: f32) -> f32

fn sin(self) -> f32

fn cos(self) -> f32

fn tan(self) -> f32

fn asin(self) -> f32

fn acos(self) -> f32

fn atan(self) -> f32

fn atan2(self, other: f32) -> f32

fn sin_cos(self) -> (f32, f32)

Simultaneously computes the sine and cosine of the number

fn exp_m1(self) -> f32

Returns the exponential of the number, minus 1, in a way that is accurate even if the number is close to zero

fn ln_1p(self) -> f32

Returns the natural logarithm of the number plus 1 (ln(1+n)) more accurately than if the operations were performed separately

fn sinh(self) -> f32

fn cosh(self) -> f32

fn tanh(self) -> f32

fn asinh(self) -> f32

Inverse hyperbolic sine

Returns

  • on success, the inverse hyperbolic sine of self will be returned
  • self if self is 0.0, -0.0, INFINITY, or NEG_INFINITY
  • NAN if self is NAN

fn acosh(self) -> f32

Inverse hyperbolic cosine

Returns

  • on success, the inverse hyperbolic cosine of self will be returned
  • INFINITY if self is INFINITY
  • NAN if self is NAN or self < 1.0 (including NEG_INFINITY)

fn atanh(self) -> f32

Inverse hyperbolic tangent

Returns

  • on success, the inverse hyperbolic tangent of self will be returned
  • self if self is 0.0 or -0.0
  • INFINITY if self is 1.0
  • NEG_INFINITY if self is -1.0
  • NAN if the self is NAN or outside the domain of -1.0 <= self <= 1.0 (including INFINITY and NEG_INFINITY)

impl SampleRange for f32

fn construct_range(low: f32, high: f32) -> Range<f32>

fn sample_range<R>(r: &Range<f32>, rng: &mut R) -> f32 where R: Rng

impl Rand for f32

fn rand<R>(rng: &mut R) -> f32 where R: Rng

Generate a floating point number in the half-open interval [0,1).

See Closed01 for the closed interval [0,1], and Open01 for the open interval (0,1).