Struct micromath::F32[][src]

pub struct F32(pub f32);

32-bit floating point wrapper which implements fast approximation-based operations.

Implementations

impl F32[src]

pub fn abs(self) -> Self[src]

Computes the absolute value of self.

Returns Self::NAN if the number is Self::NAN.

impl F32[src]

pub fn asin(self) -> Self[src]

Computes asin(x) approximation in radians in the range [-pi/2, pi/2].

impl F32[src]

pub fn atan(self) -> Self[src]

Approximates atan(x) approximation in radians with a maximum error of 0.002.

Returns Self::NAN if the number is Self::NAN.

pub fn atan_norm(self) -> Self[src]

Approximates atan(x) normalized to the [−1,1] range with a maximum error of 0.1620 degrees.

impl F32[src]

pub fn atan2(self, rhs: Self) -> Self[src]

Approximates the four quadrant arctangent of self (y) and rhs (x) in radians with a maximum error of 0.002.

  • x = 0, y = 0: 0
  • x >= 0: arctan(y/x) -> [-pi/2, pi/2]
  • y >= 0: arctan(y/x) + pi -> (pi/2, pi]
  • y < 0: arctan(y/x) - pi -> (-pi, -pi/2)

impl F32[src]

pub fn ceil(self) -> Self[src]

Returns the smallest integer greater than or equal to a number.

impl F32[src]

pub fn copysign(self, sign: Self) -> Self[src]

Returns a number composed of the magnitude of self and the sign of sign.

impl F32[src]

pub fn cos(self) -> Self[src]

Approximates cos(x) in radians with a maximum error of 0.002.

impl F32[src]

pub fn div_euclid(self, rhs: Self) -> Self[src]

Calculates Euclidean division, the matching method for rem_euclid.

impl F32[src]

pub fn exp(self) -> Self[src]

Returns e^(self), (the exponential function).

impl F32[src]

pub fn floor(self) -> Self[src]

Returns the largest integer less than or equal to a number.

impl F32[src]

pub fn fract(self) -> Self[src]

Returns the fractional part of a number with sign.

impl F32[src]

pub fn hypot(self, rhs: Self) -> Self[src]

Calculate the length of the hypotenuse of a right-angle triangle.

impl F32[src]

pub fn inv(self) -> Self[src]

Fast approximation of 1/x.

impl F32[src]

pub fn invsqrt(self) -> Self[src]

Approximate inverse square root with an average deviation of ~5%.

impl F32[src]

pub fn ln(self) -> Self[src]

Approximates the natural logarithm of the number.

impl F32[src]

pub fn log(self, base: Self) -> Self[src]

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

impl F32[src]

pub fn log10(self) -> Self[src]

Approximates the base 10 logarithm of the number.

impl F32[src]

pub fn log2(self) -> Self[src]

Approximates the base 2 logarithm of the number.

impl F32[src]

pub fn powf(self, n: Self) -> Self[src]

Approximates a number raised to a floating point power.

impl F32[src]

pub fn powi(self, n: i32) -> Self[src]

Approximates a number raised to an integer power.

impl F32[src]

pub fn rem_euclid(self, rhs: Self) -> Self[src]

Calculates the least non-negative remainder of self (mod rhs).

impl F32[src]

pub fn round(self) -> Self[src]

Returns the nearest integer to a number.

impl F32[src]

pub fn sin(self) -> Self[src]

Approximates sin(x) in radians with a maximum error of 0.002.

impl F32[src]

pub fn sqrt(self) -> Self[src]

Approximates the square root of a number with an average deviation of ~5%.

Returns Self::NAN if self is a negative number.

impl F32[src]

pub fn tan(self) -> Self[src]

Approximates tan(x) in radians with a maximum error of 0.6.

impl F32[src]

pub fn trunc(self) -> Self[src]

Returns the integer part of a number.

impl F32[src]

pub const ZERO: Self[src]

The value 0.0.

pub const ONE: Self[src]

The value 1.0.

pub const RADIX: u32[src]

The radix or base of the internal representation of f32.

pub const MANTISSA_DIGITS: u32[src]

Number of significant digits in base 2.

pub const DIGITS: u32[src]

Approximate number of significant digits in base 10.

pub const EPSILON: Self[src]

Machine epsilon value for f32.

This is the difference between 1.0 and the next larger representable number.

pub const MIN: Self[src]

Smallest finite f32 value.

pub const MIN_POSITIVE: Self[src]

Smallest positive normal f32 value.

pub const MAX: Self[src]

Largest finite f32 value.

pub const MIN_EXP: i32[src]

One greater than the minimum possible normal power of 2 exponent.

pub const MAX_EXP: i32[src]

Maximum possible power of 2 exponent.

pub const MIN_10_EXP: i32[src]

Minimum possible normal power of 10 exponent.

pub const MAX_10_EXP: i32[src]

Maximum possible power of 10 exponent.

pub const NAN: Self[src]

Not a Number (NaN).

pub const INFINITY: Self[src]

Infinity (∞).

pub const NEG_INFINITY: Self[src]

Negative infinity (−∞).

pub fn is_nan(self) -> bool[src]

Returns true if this value is NaN.

pub fn is_infinite(self) -> bool[src]

Returns true if this value is positive infinity or negative infinity, and false otherwise.

pub fn is_finite(self) -> bool[src]

Returns true if this number is neither infinite nor NaN.

pub fn is_sign_positive(self) -> bool[src]

Returns true if self has a positive sign, including +0.0, NaNs with positive sign bit and positive infinity.

pub fn is_sign_negative(self) -> bool[src]

Returns true if self has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

pub fn to_bits(self) -> u32[src]

Raw transmutation to u32.

This is currently identical to transmute::<f32, u32>(self) on all platforms.

See F32::from_bits for some discussion of the portability of this operation (there are almost no issues).

pub fn from_bits(v: u32) -> Self[src]

Raw transmutation from u32.

This is currently identical to transmute::<u32, f32>(v) on all platforms. It turns out this is incredibly portable, for two reasons:

  • Floats and Ints have the same endianness on all supported platforms.
  • IEEE-754 very precisely specifies the bit layout of floats.

See f32::from_bits for more information.

Trait Implementations

impl Add<F32> for F32[src]

type Output = F32

The resulting type after applying the + operator.

impl Add<f32> for F32[src]

type Output = F32

The resulting type after applying the + operator.

impl AddAssign<F32> for F32[src]

impl AddAssign<f32> for F32[src]

impl Clone for F32[src]

impl Component for F32[src]

This is supported on crate feature vector only.

impl Copy for F32[src]

impl Debug for F32[src]

impl Default for F32[src]

impl Display for F32[src]

impl Div<F32> for F32[src]

type Output = F32

The resulting type after applying the / operator.

impl Div<f32> for F32[src]

type Output = F32

The resulting type after applying the / operator.

impl DivAssign<F32> for F32[src]

impl DivAssign<f32> for F32[src]

impl From<f32> for F32[src]

impl From<i16> for F32[src]

impl From<i8> for F32[src]

impl From<u16> for F32[src]

impl From<u8> for F32[src]

impl FromStr for F32[src]

type Err = ParseFloatError

The associated error which can be returned from parsing.

impl Inv for F32[src]

This is supported on crate feature num-traits only.

type Output = Self

The result after applying the operator.

impl LowerExp for F32[src]

impl Mul<F32> for F32[src]

type Output = F32

The resulting type after applying the * operator.

impl Mul<f32> for F32[src]

type Output = F32

The resulting type after applying the * operator.

impl MulAssign<F32> for F32[src]

impl MulAssign<f32> for F32[src]

impl Neg for F32[src]

type Output = F32

The resulting type after applying the - operator.

impl Num for F32[src]

This is supported on crate feature num-traits only.

type FromStrRadixErr = ParseFloatError

impl One for F32[src]

This is supported on crate feature num-traits only.

impl PartialEq<F32> for F32[src]

impl PartialEq<f32> for F32[src]

impl PartialOrd<F32> for F32[src]

impl PartialOrd<f32> for F32[src]

impl Product<F32> for F32[src]

impl Rem<F32> for F32[src]

type Output = F32

The resulting type after applying the % operator.

impl Rem<f32> for F32[src]

type Output = F32

The resulting type after applying the % operator.

impl RemAssign<F32> for F32[src]

impl RemAssign<f32> for F32[src]

impl StructuralPartialEq for F32[src]

impl Sub<F32> for F32[src]

type Output = F32

The resulting type after applying the - operator.

impl Sub<f32> for F32[src]

type Output = F32

The resulting type after applying the - operator.

impl SubAssign<F32> for F32[src]

impl SubAssign<f32> for F32[src]

impl Sum<F32> for F32[src]

impl UpperExp for F32[src]

impl Zero for F32[src]

This is supported on crate feature num-traits only.

Auto Trait Implementations

impl Send for F32

impl Sync for F32

impl Unpin for F32

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> NumAssign for T where
    T: Num + NumAssignOps<T>, 
[src]

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.