pub fn 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| {
        // The division is done using the numbers without scale.
        // The dividend is scaled up to maintain precision after the
        // division

        //   222.222 -->  222222000
        //   123.456 -->     123456
        // --------       ---------
        //     1.800 <--       1800
        let numeral: i128 = a * scale;

        // The division can overflow if the dividend is divided
        // by zero.
        let res: i128 = numeral.checked_div(b).expect("Found division by zero");

        assert!(
            res.abs() <= max,
            "Overflow in multiplication presented for precision {}",
            precision
        );

        res
    };

    binary(lhs, rhs, lhs.data_type().clone(), op)
}
/// Divide two decimal primitive arrays with the same precision and scale. If
/// the precision and scale is different, then an InvalidArgumentError is
/// returned. This function panics if the dividend is divided by 0 or None.
/// This function also panics if the division produces a number larger
/// than the possible number for the array precision.
///
/// # Examples
/// ```
/// use arrow2::compute::arithmetics::decimal::div;
/// use arrow2::array::PrimitiveArray;
/// use arrow2::datatypes::DataType;
///
/// let a = PrimitiveArray::from([Some(1_00i128), Some(4_00i128), Some(6_00i128)]).to(DataType::Decimal(5, 2));
/// let b = PrimitiveArray::from([Some(1_00i128), Some(2_00i128), Some(2_00i128)]).to(DataType::Decimal(5, 2));
///
/// let result = div(&a, &b);
/// let expected = PrimitiveArray::from([Some(1_00i128), Some(2_00i128), Some(3_00i128)]).to(DataType::Decimal(5, 2));
///
/// assert_eq!(result, expected);
/// ```
Divide two decimal primitive arrays with the same precision and scale. If
the precision and scale is different, then an InvalidArgumentError is
returned. This function panics if the dividend is divided by 0 or None.
This function also panics if the division produces a number larger
than the possible number for the array precision.
Divide two decimal primitive arrays with the same precision and scale . If the precision and scale is different then an InvalidArgumentError is returned . This function panics if the dividend is divided by 0 or None . This function also panics if the division produces a number larger than the possible number for the array precision .
pub fn 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| {
        // The division is done using the numbers without scale.
        // The dividend is scaled up to maintain precision after the
        // division
        //   222.222 -->  222222000
        //   123.456 -->     123456
        // --------       ---------
        //     1.800 <--       1800
        let numeral: i128 = a * scale;
        // The division can overflow if the dividend is divided
        // by zero.
        let res: i128 = numeral.checked_div(b).expect("Found division by zero");
        assert!(
            res.abs() <= max,
            "Overflow in multiplication presented for precision {}",
            precision
        );
        res
    };
    binary(lhs, rhs, lhs.data_type().clone(), op)
}
pub fn 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 | { // The division is done using the numbers without scale. // The dividend is scaled up to maintain precision after the // division //   222.222 -->  222222000 //   123.456 -->     123456 // --------       --------- //     1.800 <--       1800 let numeral : i128 = a * scale ; // The division can overflow if the dividend is divided // by zero. let res : i128 = numeral . checked_div ( b ) . expect ( " " ) ; assert ! ( res abs ( ) max " " precision ) ; res } ; binary ( lhs , rhs , lhs . data_type ( ) . clone ( ) , op ) }
Divide two decimal primitive arrays with the same precision and scale.
Divide 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::div;
use arrow2::array::PrimitiveArray;
use arrow2::datatypes::DataType.





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