Trait Float

Source
pub trait Float {
    // Required methods
    fn abs(self) -> Self;
    fn atan(self) -> Self;
    fn atan2(self, _: Self) -> Self;
    fn is_infinite(self) -> bool;
    fn is_nan(self) -> bool;
    fn sqrt(self) -> Self;
}
Expand description

Trait that provides mathematical functions for floating point numbers

§Fine print

This trait is meant to be a “closed” extension trait that’s not meant to be implemented by downstream users. As such this trait is exempted from semver rules in the context of adding new methods to it. Therefore: if you implement this trait (don’t do that), your code may (will!) break during a minor version bump. You have been warned!

Required Methods§

Source

fn abs(self) -> Self

Computes the absolute value of self. Returns NAN if the number is NAN.

Source

fn atan(self) -> Self

Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2]

Source

fn atan2(self, _: Self) -> Self

Computes the four quadrant arctangent of self (y) and other (x)

  • 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)
Source

fn is_infinite(self) -> bool

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

Source

fn is_nan(self) -> bool

Returns true if this value is NaN and false otherwise.

Source

fn sqrt(self) -> Self

Takes the square root of a number

Returns NaN if self is a negative number

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Float for f32

Source§

fn abs(self) -> Self

Source§

fn atan(self) -> Self

Source§

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

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn sqrt(self) -> Self

Source§

impl Float for f64

Source§

fn abs(self) -> Self

Source§

fn atan(self) -> Self

Source§

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

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn sqrt(self) -> Self

Implementors§