pub trait Sign {
// Required methods
fn kernel_copysign(self, sign: &Self) -> Self;
fn kernel_signum(self) -> Self;
fn kernel_is_sign_negative(&self) -> bool;
fn kernel_is_sign_positive(&self) -> bool;
}
Expand description
Provides methods for sign manipulation and checking.
Required Methods§
Sourcefn kernel_copysign(self, sign: &Self) -> Self
fn kernel_copysign(self, sign: &Self) -> Self
Returns a number with the magnitude of self
and the sign of sign
.
Sourcefn kernel_signum(self) -> Self
fn kernel_signum(self) -> Self
Computes the signum.
The returned value is:
1.0
if the value is positive, +0.0 or +∞−1.0
if the value is negative, −0.0 or −∞NaN
if the value is NaN
Sourcefn kernel_is_sign_negative(&self) -> bool
fn kernel_is_sign_negative(&self) -> bool
Returns true
if the value is negative, −0 or NaN with a negative sign.
Sourcefn kernel_is_sign_positive(&self) -> bool
fn kernel_is_sign_positive(&self) -> bool
Returns true
if the value is positive, +0 or NaN with a positive 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 Sign for f64
impl Sign for f64
Source§fn kernel_copysign(self, sign: &Self) -> Self
fn kernel_copysign(self, sign: &Self) -> Self
Returns a number with the magnitude of self
and the sign of sign
.
Source§fn kernel_is_sign_negative(&self) -> bool
fn kernel_is_sign_negative(&self) -> bool
Returns true
if the value is negative, −0 or NaN with a negative sign.
Source§fn kernel_is_sign_positive(&self) -> bool
fn kernel_is_sign_positive(&self) -> bool
Returns true
if the value is positive, +0 or NaN with a positive sign.
Source§fn kernel_signum(self) -> Self
fn kernel_signum(self) -> Self
Computes the signum.
The returned value is:
1.0
if the value is positive, +0.0 or +∞−1.0
if the value is negative, −0.0 or −∞NaN
if the value is NaN
Source§impl Sign for Float
impl Sign for Float
Source§fn kernel_copysign(self, sign: &Self) -> Self
fn kernel_copysign(self, sign: &Self) -> Self
Returns a number with the magnitude of self
and the sign of sign
.
Source§fn kernel_is_sign_negative(&self) -> bool
fn kernel_is_sign_negative(&self) -> bool
Returns true
if the value is negative, −0 or NaN with a negative sign.
Source§fn kernel_is_sign_positive(&self) -> bool
fn kernel_is_sign_positive(&self) -> bool
Returns true
if the value is positive, +0 or NaN with a positive sign.
Source§fn kernel_signum(self) -> Self
fn kernel_signum(self) -> Self
Returns the signum of the number.
This method relies on rug::Float::signum()
.
The behavior for special values is as follows:
- If the number is positive and not zero, returns
1.0
. - If the number is negative and not zero, returns
-1.0
. - If the number is zero,
rug::Float::signum()
returns1.0
(representing positive zero).