pub fn checked_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 result: i128 = a + b;

        if result.abs() > max {
            None
        } else {
            Some(result)
        }
    };

    binary_checked(lhs, rhs, lhs.data_type().clone(), op)
}
/// Checked addition 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 sum is larger than
/// the possible number with the selected precision (overflowing), then the
/// validity for that index is changed to None
///
/// # Examples
/// ```
/// use arrow2::compute::arithmetics::decimal::checked_add;
/// use arrow2::array::PrimitiveArray;
/// use arrow2::datatypes::DataType;
///
/// let a = PrimitiveArray::from([Some(99000i128), Some(11100i128), None, Some(22200i128)]).to(DataType::Decimal(5, 2));
/// let b = PrimitiveArray::from([Some(01000i128), Some(22200i128), None, Some(11100i128)]).to(DataType::Decimal(5, 2));
///
/// let result = checked_add(&a, &b);
/// let expected = PrimitiveArray::from([None, Some(33300i128), None, Some(33300i128)]).to(DataType::Decimal(5, 2));
///
/// assert_eq!(result, expected);
/// ```
Checked addition 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 sum is larger than
the possible number with the selected precision (overflowing), then the
validity for that index is changed to None
Checked addition 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 sum is larger than the possible number with the selected precision ( overflowing ) then the validity for that index is changed to None
pub fn checked_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 result: i128 = a + b;
        if result.abs() > max {
            None
        } else {
            Some(result)
        }
    };
    binary_checked(lhs, rhs, lhs.data_type().clone(), op)
}
pub fn checked_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 result : i128 = a + b ; if result . abs ( ) > max { None } else { Some ( result ) } } ; binary_checked ( lhs , rhs , lhs . data_type ( ) . clone ( ) , op ) }
Checked addition of two decimal primitive arrays with the same precision
and scale.
Checked addition 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::checked_add;
use arrow2::array::PrimitiveArray;
use arrow2::datatypes::DataType.





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