pub fn saturating_div(
    lhs: &PrimitiveArray<i128>,
    rhs: &PrimitiveArray<i128>,
) -> PrimitiveArray<i128> {
    let (precision, scale) = get_parameters(lhs.data_type(), rhs.data_type()).unwrap();

    let scale = 10i128.pow(scale as u32);
    let max = max_value(precision);

    let op = move |a: i128, b: i128| {
        let numeral: i128 = a * scale;

        match numeral.checked_div(b) {
            Some(res) => match res {
                res if res.abs() > max => {
                    if res > 0 {
                        max
                    } else {
                        -max
                    }
                }
                _ => res,
            },
            None => 0,
        }
    };

    binary(lhs, rhs, lhs.data_type().clone(), op)
}
/// Saturated division of two decimal primitive arrays with the same
/// precision and scale. If the precision and scale is different, then an
/// InvalidArgumentError is returned. If the result from the division is
/// larger than the possible number with the selected precision then the
/// resulted number in the arrow array is the maximum number for the selected
/// precision. The function panics if divided by zero.
///
/// # Examples
/// ```
/// use arrow2::compute::arithmetics::decimal::saturating_div;
/// use arrow2::array::PrimitiveArray;
/// use arrow2::datatypes::DataType;
///
/// let a = PrimitiveArray::from([Some(999_99i128), Some(4_00i128), Some(6_00i128)]).to(DataType::Decimal(5, 2));
/// let b = PrimitiveArray::from([Some(000_01i128), Some(2_00i128), Some(2_00i128)]).to(DataType::Decimal(5, 2));
///
/// let result = saturating_div(&a, &b);
/// let expected = PrimitiveArray::from([Some(999_99i128), Some(2_00i128), Some(3_00i128)]).to(DataType::Decimal(5, 2));
///
/// assert_eq!(result, expected);
/// ```
Saturated division of two decimal primitive arrays with the same
precision and scale. If the precision and scale is different, then an
InvalidArgumentError is returned. If the result from the division is
larger than the possible number with the selected precision then the
resulted number in the arrow array is the maximum number for the selected
precision. The function panics if divided by zero.
Saturated division of two decimal primitive arrays with the same precision and scale . If the precision and scale is different then an InvalidArgumentError is returned . If the result from the division is larger than the possible number with the selected precision then the resulted number in the arrow array is the maximum number for the selected precision . The function panics if divided by zero .
pub fn saturating_div(
    lhs: &PrimitiveArray<i128>,
    rhs: &PrimitiveArray<i128>,
) -> PrimitiveArray<i128> {
    let (precision, scale) = get_parameters(lhs.data_type(), rhs.data_type()).unwrap();
    let scale = 10i128.pow(scale as u32);
    let max = max_value(precision);
    let op = move |a: i128, b: i128| {
        let numeral: i128 = a * scale;
        match numeral.checked_div(b) {
            Some(res) => match res {
                res if res.abs() > max => {
                    if res > 0 {
                        max
                    } else {
                        -max
                    }
                }
                _ => res,
            },
            None => 0,
        }
    };
    binary(lhs, rhs, lhs.data_type().clone(), op)
}
pub fn saturating_div ( lhs : & PrimitiveArray < i128 > , rhs : & PrimitiveArray < i128 > , ) -> PrimitiveArray < i128 > { let ( precision , scale ) = get_parameters ( lhs . data_type ( ) , rhs . data_type ( ) ) . unwrap ( ) ; let scale = 10i128 . pow ( scale as u32 ) ; let max = max_value ( precision ) ; let op = move | a : i128 , b : i128 | { let numeral : i128 = a * scale ; match numeral . checked_div ( b ) { Some ( res ) => match res { res if res . abs ( ) > max => { if res > 0 { max } else { - max } } _ => res , } , None => 0 , } } ; binary ( lhs , rhs , lhs . data_type ( ) . clone ( ) , op ) }
Saturated division of two decimal primitive arrays with the same
precision and scale.
Saturated division of two decimal primitive arrays with the same precision and scale .
lhs
&PrimitiveArray<i128>
rhs
&PrimitiveArray<i128>
lhs
&PrimitiveArray<i128>
rhs
&PrimitiveArray<i128>
examples
```
use arrow2::compute::arithmetics::decimal::saturating_div;
use arrow2::array::PrimitiveArray;
use arrow2::datatypes::DataType.





assert_eq!(result, expected);
```
` ` ` use arrow2 :: compute :: arithmetics :: decimal :: saturating_div ; use arrow2 :: array :: PrimitiveArray ; use arrow2 :: datatypes :: DataType . assert_eq! ( result expected ) ; ` ` `