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

    let max = max_value(precision);

    let op = move |a, b| {
        let res: i128 = a - b;

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

        res
    };

    binary(lhs, rhs, lhs.data_type().clone(), op)
}
/// Subtract 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 subtracted numbers result in a number
/// smaller than the possible number for the selected precision.
///
/// # Examples
/// ```
/// use arrow2::compute::arithmetics::decimal::sub;
/// use arrow2::array::PrimitiveArray;
/// use arrow2::datatypes::DataType;
///
/// let a = PrimitiveArray::from([Some(1i128), Some(1i128), None, Some(2i128)]).to(DataType::Decimal(5, 2));
/// let b = PrimitiveArray::from([Some(1i128), Some(2i128), None, Some(2i128)]).to(DataType::Decimal(5, 2));
///
/// let result = sub(&a, &b);
/// let expected = PrimitiveArray::from([Some(0i128), Some(-1i128), None, Some(0i128)]).to(DataType::Decimal(5, 2));
///
/// assert_eq!(result, expected);
/// ```
Subtract 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 subtracted numbers result in a number
smaller than the possible number for the selected precision.
Subtract 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 subtracted numbers result in a number smaller than the possible number for the selected precision .
pub fn sub(lhs: &PrimitiveArray<i128>, rhs: &PrimitiveArray<i128>) -> PrimitiveArray<i128> {
    let (precision, _) = get_parameters(lhs.data_type(), rhs.data_type()).unwrap();
    let max = max_value(precision);
    let op = move |a, b| {
        let res: i128 = a - b;
        assert!(
            res.abs() <= max,
            "Overflow in subtract presented for precision {}",
            precision
        );
        res
    };
    binary(lhs, rhs, lhs.data_type().clone(), op)
}
pub fn sub ( lhs : & PrimitiveArray < i128 > , rhs : & PrimitiveArray < i128 > ) -> PrimitiveArray < i128 > { let ( precision , _ ) = get_parameters ( lhs . data_type ( ) , rhs . data_type ( ) ) . unwrap ( ) ; let max = max_value ( precision ) ; let op = move | a , b | { let res : i128 = a - b ; assert ! ( res abs ( ) max " " precision ) ; res } ; binary ( lhs , rhs , lhs . data_type ( ) . clone ( ) , op ) }
Subtract two decimal primitive arrays with the same precision and scale.
Subtract 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::sub;
use arrow2::array::PrimitiveArray;
use arrow2::datatypes::DataType.





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