Function arrow2::compute::arithmetics::basic::saturating_sub_scalar
source · [−]pub fn saturating_sub_scalar<T>(
lhs: &PrimitiveArray<T>,
rhs: &T
) -> PrimitiveArray<T> where
T: NativeArithmetics + SaturatingSub<Output = T>,
Expand description
Saturated subtraction of a scalar T to a primitive array of type T. If the result from the sub is smaller than the possible number for this type, then the result will be saturated
Examples
use arrow2::compute::arithmetics::basic::saturating_sub_scalar;
use arrow2::array::Int8Array;
let a = Int8Array::from(&[Some(-100i8)]);
let result = saturating_sub_scalar(&a, &100i8);
let expected = Int8Array::from(&[Some(-128i8)]);
assert_eq!(result, expected);