Function polars::export::arrow::compute::arithmetics::basic::overflowing_add
source · [−]pub fn overflowing_add<T>(
lhs: &PrimitiveArray<T>,
rhs: &PrimitiveArray<T>
) -> (PrimitiveArray<T>, Bitmap) where
T: NativeArithmetics + OverflowingAdd<Output = T>,
This is supported on crate feature
compute_arithmetics
only.Expand description
Overflowing 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 an array with overflowed values and a validity array indicating the overflowing elements from the array.
Examples
use arrow2::compute::arithmetics::basic::overflowing_add;
use arrow2::array::PrimitiveArray;
let a = PrimitiveArray::from([Some(1i8), Some(100i8)]);
let b = PrimitiveArray::from([Some(1i8), Some(100i8)]);
let (result, overflow) = overflowing_add(&a, &b);
let expected = PrimitiveArray::from([Some(2i8), Some(-56i8)]);
assert_eq!(result, expected);