micromath

Trait F32Ext

Source
pub trait F32Ext: Sized {
Show 33 methods // Required methods fn abs(self) -> f32; fn acos(self) -> f32; fn asin(self) -> f32; fn atan(self) -> f32; fn atan_norm(self) -> f32; fn atan2(self, other: f32) -> f32; fn atan2_norm(self, other: f32) -> f32; fn ceil(self) -> f32; fn copysign(self, sign: f32) -> 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 hypot(self, other: f32) -> f32; fn inv(self) -> f32; fn invsqrt(self) -> f32; fn ln(self) -> f32; fn log(self, base: f32) -> f32; fn log2(self) -> f32; fn log10(self) -> f32; fn mul_add(self, a: f32, b: f32) -> 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 signum(self) -> f32; fn sin(self) -> f32; fn sin_cos(self) -> (f32, f32); fn sqrt(self) -> f32; fn tan(self) -> f32; fn trunc(self) -> f32;
}
Expand description

f32 extension providing various arithmetic approximations and polyfills for std functionality.

Required Methods§

Source

fn abs(self) -> f32

Compute absolute value with a constant-time, data-independent implementation.

Source

fn acos(self) -> f32

Approximates acos(x) in radians in the range [0, pi]

Source

fn asin(self) -> f32

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

Source

fn atan(self) -> f32

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

Source

fn atan_norm(self) -> f32

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

Source

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

Approximates the four quadrant arctangent atan2(x) in radians, with a maximum error of 0.002.

Source

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

Approximates the four quadrant arctangent. Normalized to the [0,4) range with a maximum error of 0.1620 degrees.

Source

fn ceil(self) -> f32

Approximates floating point ceiling.

Source

fn copysign(self, sign: f32) -> f32

Copies the sign from one number to another and returns it.

Source

fn cos(self) -> f32

Approximates cosine in radians with a maximum error of 0.002.

Source

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

Calculates Euclidean division, the matching method for rem_euclid.

Source

fn exp(self) -> f32

Approximates e^x.

Source

fn floor(self) -> f32

Approximates floating point floor.

Source

fn fract(self) -> f32

Retrieve the fractional part of floating point with sign.

Source

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

Approximates the length of the hypotenuse of a right-angle triangle given legs of length x and y.

Source

fn inv(self) -> f32

Approximates 1/x with an average deviation of ~8%.

Source

fn invsqrt(self) -> f32

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

Source

fn ln(self) -> f32

Approximates ln(x).

Source

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

Approximates log with an arbitrary base.

Source

fn log2(self) -> f32

Approximates log2.

Source

fn log10(self) -> f32

Approximates log10.

Source

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

Computes (self * a) + b.

Source

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

Approximates self^n.

Source

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

Approximates self^n where n is an i32

Source

fn recip(self) -> f32

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

Source

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

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

Source

fn round(self) -> f32

Round the number part of floating point with sign.

Source

fn signum(self) -> f32

Returns a number that represents the sign of self.

Source

fn sin(self) -> f32

Approximates sine in radians with a maximum error of 0.002.

Source

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

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

Source

fn sqrt(self) -> f32

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

Source

fn tan(self) -> f32

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

Source

fn trunc(self) -> f32

Retrieve whole number part of floating point with sign.

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 F32Ext for f32

Source§

fn abs(self) -> f32

Source§

fn acos(self) -> f32

Source§

fn asin(self) -> f32

Source§

fn atan(self) -> f32

Source§

fn atan_norm(self) -> f32

Source§

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

Source§

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

Source§

fn ceil(self) -> f32

Source§

fn copysign(self, sign: f32) -> f32

Source§

fn cos(self) -> f32

Source§

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

Source§

fn exp(self) -> f32

Source§

fn floor(self) -> f32

Source§

fn fract(self) -> f32

Source§

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

Source§

fn inv(self) -> f32

Source§

fn invsqrt(self) -> f32

Source§

fn ln(self) -> f32

Source§

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

Source§

fn log2(self) -> f32

Source§

fn log10(self) -> f32

Source§

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

Source§

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

Source§

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

Source§

fn recip(self) -> f32

Source§

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

Source§

fn round(self) -> f32

Source§

fn signum(self) -> f32

Source§

fn sin(self) -> f32

Source§

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

Source§

fn sqrt(self) -> f32

Source§

fn tan(self) -> f32

Source§

fn trunc(self) -> f32

Implementors§