pub fn saturating_add<T>(
    lhs: &PrimitiveArray<T>,
    rhs: &PrimitiveArray<T>
) -> PrimitiveArray<T> where
    T: NativeArithmetics + SaturatingAdd<Output = T>, 
Available on crate feature compute_arithmetics only.
Expand description

Saturating addition of two primitive arrays. If the result from the sum is larger than the possible number for this type, the result for the operation will be the saturated value.

Examples

use arrow2::compute::arithmetics::basic::saturating_add;
use arrow2::array::PrimitiveArray;

let a = PrimitiveArray::from([Some(100i8)]);
let b = PrimitiveArray::from([Some(100i8)]);
let result = saturating_add(&a, &b);
let expected = PrimitiveArray::from([Some(127)]);
assert_eq!(result, expected);