Function arrow2::compute::arithmetics::basic::overflowing_sub
source · [−]pub fn overflowing_sub<T>(
lhs: &PrimitiveArray<T>,
rhs: &PrimitiveArray<T>
) -> (PrimitiveArray<T>, Bitmap) where
T: NativeArithmetics + OverflowingSub<Output = T>,
Expand description
Overflowing subtraction of two primitive arrays. If the result from the sub is smaller 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_sub;
use arrow2::array::Int8Array;
let a = Int8Array::from(&[Some(1i8), Some(-100i8)]);
let b = Int8Array::from(&[Some(1i8), Some(100i8)]);
let (result, overflow) = overflowing_sub(&a, &b);
let expected = Int8Array::from(&[Some(0i8), Some(56i8)]);
assert_eq!(result, expected);