pub fn rem(self, other: Self) -> Result<Self, NumberError> {
        if let (Ok(a), Ok(b)) = (self.try_as_i128(), other.try_as_i128()) {
            match b {
                // Fallthrough for zero denominator.
                0 => {}
                // Avoid Rust's special treatment of `-2^127 % -1`.
                -1 => return Ok(Self(N::I(0))),
                // All other cases involving integer will never overflow.
                _ => return Ok(Self(N::I(a % b))),
            }
        }

        let denominator = f64::from(other);
        if denominator == 0.0 {
            // Divide by zero is _always_ NULL in SQL, never infinity.
            Err(NumberError::NaN)
        } else {
            Ok(Self::from_finite_f64(f64::from(self) % denominator))
        }
    }
/// Computes the remainder (modulus) when this number is divided by another number.
Computes the remainder (modulus) when this number is divided by another number.
Computes the remainder ( modulus ) when this number is divided by another number .
pub fn rem(self, other: Self) -> Result<Self, NumberError> {
        if let (Ok(a), Ok(b)) = (self.try_as_i128(), other.try_as_i128()) {
            match b {
                // Fallthrough for zero denominator.
                0 => {}
                // Avoid Rust's special treatment of `-2^127 % -1`.
                -1 => return Ok(Self(N::I(0))),
                // All other cases involving integer will never overflow.
                _ => return Ok(Self(N::I(a % b))),
            }
        }
        let denominator = f64::from(other);
        if denominator == 0.0 {
            // Divide by zero is _always_ NULL in SQL, never infinity.
            Err(NumberError::NaN)
        } else {
            Ok(Self::from_finite_f64(f64::from(self) % denominator))
        }
    }
pub fn rem ( self , other : Self ) -> Result < Self , NumberError > { if let ( Ok ( a ) , Ok ( b ) ) = ( self . try_as_i128 ( ) , other . try_as_i128 ( ) ) { match b { // Fallthrough for zero denominator. 0 => { } // Avoid Rust's special treatment of `-2^127 % -1`. - 1 => return Ok ( Self ( N :: I ( 0 ) ) ) , // All other cases involving integer will never overflow. _ => return Ok ( Self ( N :: I ( a % b ) ) ) , } } let denominator = f64 :: from ( other ) ; if denominator == 0.0 { // Divide by zero is _always_ NULL in SQL, never infinity. Err ( NumberError :: NaN ) } else { Ok ( Self :: from_finite_f64 ( f64 :: from ( self ) % denominator ) ) } }
Computes the remainder (modulus) when this number is divided by another number.
Computes the remainder ( modulus ) when this number is divided by another number .
self
other
Self
self
other
Self