pub fn add(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 addition presented for precision {}",
            precision
        );

        res
    };

    binary(lhs, rhs, lhs.data_type().clone(), op)
}
/// Adds two decimal [`PrimitiveArray`] with the same precision and scale.
/// # Error
/// Errors if the precision and scale are different.
/// # Panic
/// This function panics iff the added numbers result in a number larger than
/// the possible number for the precision.
///
/// # Examples
/// ```
/// use arrow2::compute::arithmetics::decimal::add;
/// 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 = add(&a, &b);
/// let expected = PrimitiveArray::from([Some(2i128), Some(3i128), None, Some(4i128)]).to(DataType::Decimal(5, 2));
///
/// assert_eq!(result, expected);
/// ```
Adds two decimal [`PrimitiveArray`] with the same precision and scale.
Adds two decimal [ ` PrimitiveArray ` ] with the same precision and scale .
pub fn add(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 addition presented for precision {}",
            precision
        );
        res
    };
    binary(lhs, rhs, lhs.data_type().clone(), op)
}
pub fn add ( 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 ) }
Adds two decimal [`PrimitiveArray`] with the same precision and scale.
Adds two decimal [ ` PrimitiveArray ` ] with the same precision and scale .
lhs
&PrimitiveArray<i128>
rhs
&PrimitiveArray<i128>
lhs
&PrimitiveArray<i128>
rhs
&PrimitiveArray<i128>
error
Errors if the precision and scale are different.
Errors if the precision and scale are different .
panic
This function panics iff the added numbers result in a number larger than
the possible number for the precision.
This function panics iff the added numbers result in a number larger than the possible number for the precision .
examples
```
use arrow2::compute::arithmetics::decimal::add;
use arrow2::array::PrimitiveArray;
use arrow2::datatypes::DataType.





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