Function polars::export::arrow::compute::arithmetics::basic::saturating_sub
source · [−]pub fn saturating_sub<T>(
lhs: &PrimitiveArray<T>,
rhs: &PrimitiveArray<T>
) -> PrimitiveArray<T> where
T: NativeArithmetics + SaturatingSub<Output = T>,
This is supported on crate feature
compute_arithmetics
only.Expand description
Saturating 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 the saturated value.
Examples
use arrow2::compute::arithmetics::basic::saturating_sub;
use arrow2::array::Int8Array;
let a = Int8Array::from(&[Some(-100i8)]);
let b = Int8Array::from(&[Some(100i8)]);
let result = saturating_sub(&a, &b);
let expected = Int8Array::from(&[Some(-128)]);
assert_eq!(result, expected);