Struct rustduino::math::F32[][src]

pub struct F32(pub f32);
Expand description

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

Implementations

Computes the absolute value of self.

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

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

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

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

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

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)

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

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

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

Calculates Euclidean division, the matching method for rem_euclid.

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

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

Returns the fractional part of a number with sign.

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

Fast approximation of 1/x.

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

Approximates the natural logarithm of the number.

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

Approximates the base 10 logarithm of the number.

Approximates the base 2 logarithm of the number.

Approximates a number raised to a floating point power.

Approximates a number raised to an integer power.

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

Returns the nearest integer to a number.

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

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

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

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

Returns the integer part of a number.

The value 0.0.

The value 1.0.

The radix or base of the internal representation of f32.

Number of significant digits in base 2.

Approximate number of significant digits in base 10.

Machine epsilon value for f32.

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

Smallest finite f32 value.

Smallest positive normal f32 value.

Largest finite f32 value.

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

Maximum possible power of 2 exponent.

Minimum possible normal power of 10 exponent.

Maximum possible power of 10 exponent.

Not a Number (NaN).

Infinity (∞).

Negative infinity (−∞).

Returns true if this value is NaN.

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

Returns true if this number is neither infinite nor NaN.

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

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

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

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

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Formats the value using the given formatter.

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

Performs the %= operation. Read more

Performs the %= operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.