Function polars::export::arrow::compute::arithmetics::basic::wrapping_add
source · [−]pub fn wrapping_add<T>(
lhs: &PrimitiveArray<T>,
rhs: &PrimitiveArray<T>
) -> PrimitiveArray<T> where
T: NativeArithmetics + WrappingAdd<Output = T>,
This is supported on crate feature
compute_arithmetics
only.Expand description
Wrapping addition of two PrimitiveArray
s.
It wraps around at the boundary of the type if the result overflows.
Examples
use arrow2::compute::arithmetics::basic::wrapping_add;
use arrow2::array::PrimitiveArray;
let a = PrimitiveArray::from([Some(-100i8), Some(100i8), Some(100i8)]);
let b = PrimitiveArray::from([Some(0i8), Some(100i8), Some(0i8)]);
let result = wrapping_add(&a, &b);
let expected = PrimitiveArray::from([Some(-100i8), Some(-56i8), Some(100i8)]);
assert_eq!(result, expected);