Trait geng::prelude::Float

pub trait Float: Num {
    const PI: Self;
Show 26 methods // Required methods fn acos(self) -> Self; fn asin(self) -> Self; fn atan(self) -> Self; fn atan2(y: Self, x: Self) -> Self; fn ceil(self) -> Self; fn cos(self) -> Self; fn div_euclid(self, other: Self) -> Self; fn exp(self) -> Self; fn floor(self) -> Self; fn fract(self) -> Self; fn is_finite(self) -> bool; fn ln(self) -> Self; fn log(self, base: Self) -> Self; fn log10(self) -> Self; fn log2(self) -> Self; fn powf(self, n: Self) -> Self; fn powi(self, n: i32) -> Self; fn recip(self) -> Self; fn rem_euclid(self, other: Self) -> Self; fn round(self) -> Self; fn sin(self) -> Self; fn sin_cos(self) -> (Self, Self); fn sqrt(self) -> Self; fn tan(self) -> Self; fn from_f32(x: f32) -> Self; fn as_f32(self) -> f32;
}
Expand description

Floating point number, including NaN/Inf

Required Associated Constants§

const PI: Self

Archimedes’ constant (π)

Required Methods§

fn acos(self) -> Self

Computes the arccosine of a number.

Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1].

fn asin(self) -> Self

Computes the arcsine of a number.

Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1].

fn atan(self) -> Self

Computes the arctangent of a number.

Return value is in radians in the range [-pi/2, pi/2];

fn atan2(y: Self, x: Self) -> Self

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

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

fn ceil(self) -> Self

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

fn cos(self) -> Self

Computes the cosine of a number (in radians).

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

Calculates Euclidean division, the matching method for rem_euclid.

This computes the integer n such that self = n * rhs + self.rem_euclid(rhs). In other words, the result is self / rhs rounded to the integer n such that self >= n * rhs.

fn exp(self) -> Self

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

fn floor(self) -> Self

Returns the largest integer less than or equal to self.

fn fract(self) -> Self

Returns the fractional part of self.

fn is_finite(self) -> bool

Returns true if this number is neither infinite nor NaN.

fn ln(self) -> Self

Returns the natural logarithm of the number.

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

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

fn log10(self) -> Self

Returns the base 10 logarithm of the number.

fn log2(self) -> Self

Returns the base 2 logarithm of the number.

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

Raises a number to a floating point power.

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

Raises a number to an integer power.

fn recip(self) -> Self

Takes the reciprocal (inverse) of a number, 1/x

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

Calculates the least nonnegative remainder of self (mod rhs).

In particular, the return value r satisfies 0.0 <= r < rhs.abs() in most cases. However, due to a floating point round-off error it can result in r == rhs.abs(), violating the mathematical definition, if self is much smaller than rhs.abs() in magnitude and self < 0.0. This result is not an element of the function’s codomain, but it is the closest floating point number in the real numbers and thus fulfills the property self == self.div_euclid(rhs) * rhs + self.rem_euclid(rhs) approximately.

fn round(self) -> Self

Returns the nearest integer to self. Round half-way cases away from 0.0.

fn sin(self) -> Self

Computes the sine of a number (in radians).

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

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

fn sqrt(self) -> Self

Returns the square root of a number.

Returns NaN if self is a negative number other than -0.0.

fn tan(self) -> Self

Computes the tangent of a number (in radians).

fn from_f32(x: f32) -> Self

Convert an f32 into Self

fn as_f32(self) -> f32

Convert self into an f32

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

§

impl Float for f32

§

const PI: f32 = 3.14159274f32

§

fn acos(self) -> f32

§

fn asin(self) -> f32

§

fn atan(self) -> f32

§

fn atan2(y: f32, x: f32) -> f32

§

fn ceil(self) -> f32

§

fn cos(self) -> f32

§

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

§

fn exp(self) -> f32

§

fn floor(self) -> f32

§

fn fract(self) -> f32

§

fn is_finite(self) -> bool

§

fn ln(self) -> f32

§

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

§

fn log10(self) -> f32

§

fn log2(self) -> f32

§

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

§

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

§

fn recip(self) -> f32

§

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

§

fn round(self) -> f32

§

fn sin(self) -> f32

§

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

§

fn sqrt(self) -> f32

§

fn tan(self) -> f32

§

fn from_f32(x: f32) -> f32

§

fn as_f32(self) -> f32

§

impl Float for f64

§

const PI: f64 = 3.1415926535897931f64

§

fn acos(self) -> f64

§

fn asin(self) -> f64

§

fn atan(self) -> f64

§

fn atan2(y: f64, x: f64) -> f64

§

fn ceil(self) -> f64

§

fn cos(self) -> f64

§

fn div_euclid(self, other: f64) -> f64

§

fn exp(self) -> f64

§

fn floor(self) -> f64

§

fn fract(self) -> f64

§

fn is_finite(self) -> bool

§

fn ln(self) -> f64

§

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

§

fn log10(self) -> f64

§

fn log2(self) -> f64

§

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

§

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

§

fn recip(self) -> f64

§

fn rem_euclid(self, other: f64) -> f64

§

fn round(self) -> f64

§

fn sin(self) -> f64

§

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

§

fn sqrt(self) -> f64

§

fn tan(self) -> f64

§

fn from_f32(x: f32) -> f64

§

fn as_f32(self) -> f32

Implementors§

§

impl<T> Float for T
where T: Real,

§

const PI: T = <Self as Real>::PI