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§
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(self, _: Self) -> Self
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)
Sourcefn is_infinite(self) -> bool
fn is_infinite(self) -> bool
Returns true
if this value is positive infinity or negative infinity
and false
otherwise.
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.