Trait Signum

Source
pub trait Signum {
    // Required methods
    const fn signum(self) -> Self;
    const fn signum_i128(self) -> i128;
}
Expand description

✅ The sign of the number.

Returns:

  • 1.0 if positive,
  • 0.0 if zero,
  • -1.0 if negative.

§Panics

This function never panics.

Required Methods§

Source

const fn signum(self) -> Self

Source

const fn signum_i128(self) -> i128

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.

Implementors§

Source§

impl Signum for Dec19x19

§Tests

check! ( [Dec19x19::signum] {
    (Dec19x19::MAX)   => Dec19x19!(1.0),
    (Dec19x19!(3.0))  => Dec19x19!(1.0),
    (Dec19x19!(0.0))  => Dec19x19!(0.0),
    (Dec19x19!(-3.0)) => Dec19x19!(-1.0),
    (Dec19x19::MIN)   => Dec19x19!(-1.0),
});