Function polars::export::arrow::compute::arithmetics::basic::saturating_add_scalar
source · [−]pub fn saturating_add_scalar<T>(
lhs: &PrimitiveArray<T>,
rhs: &T
) -> PrimitiveArray<T> where
T: NativeArithmetics + SaturatingAdd<Output = T>,
This is supported on crate feature
compute_arithmetics
only.Expand description
Saturated addition of a scalar T to a primitive array of type T. If the result from the sum is larger than the possible number for this type, then the result will be saturated
Examples
use arrow2::compute::arithmetics::basic::saturating_add_scalar;
use arrow2::array::PrimitiveArray;
let a = PrimitiveArray::from([Some(100i8)]);
let result = saturating_add_scalar(&a, &100i8);
let expected = PrimitiveArray::from([Some(127)]);
assert_eq!(result, expected);