pub trait Real: Num + Copy {
const PI: Self;
Show 25 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 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
Real number (differs from Float as doesn’t support NaN)
Required Associated Constants§
Required Methods§
Sourcefn acos(self) -> Self
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].
Sourcefn asin(self) -> Self
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].
Sourcefn atan(self) -> Self
fn atan(self) -> Self
Computes the arctangent of a number.
Return value is in radians in the range [-pi/2, pi/2];
Sourcefn atan2(y: Self, x: Self) -> Self
fn atan2(y: Self, x: Self) -> Self
Computes the four quadrant arctangent of self (y) and other (x) in radians.
x = 0,y = 0:0x >= 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)
Sourcefn div_euclid(self, other: Self) -> Self
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.
Sourcefn log(self, base: Self) -> Self
fn log(self, base: Self) -> Self
Returns the logarithm of the number with respect to an arbitrary base.
Sourcefn rem_euclid(self, other: Self) -> Self
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.
Sourcefn round(self) -> Self
fn round(self) -> Self
Returns the nearest integer to self.
Round half-way cases away from 0.0.
Sourcefn sin_cos(self) -> (Self, Self)
fn sin_cos(self) -> (Self, Self)
Simultaneously computes the sine and cosine of the number, x.
Returns (sin(x), cos(x)).
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.