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

Checked subtraction of two primitive arrays. If the result from the subtraction overflow, the validity for that index is changed

Examples

use arrow2::compute::arithmetics::basic::checked_sub;
use arrow2::array::Int8Array;

let a = Int8Array::from(&[Some(100i8), Some(-100i8), Some(100i8)]);
let b = Int8Array::from(&[Some(1i8), Some(100i8), Some(0i8)]);
let result = checked_sub(&a, &b);
let expected = Int8Array::from(&[Some(99i8), None, Some(100i8)]);
assert_eq!(result, expected);