pub fn checked_mul(
    lhs: &PrimitiveArray<i128>,
    rhs: &PrimitiveArray<i128>
) -> PrimitiveArray<i128>
Available on crate feature compute_arithmetics only.
Expand description

Checked multiplication of two decimal primitive arrays with the same precision and scale. If the precision and scale is different, then an InvalidArgumentError is returned. If the result from the mul is larger than the possible number with the selected precision (overflowing), then the validity for that index is changed to None

Examples

use arrow2::compute::arithmetics::decimal::checked_mul;
use arrow2::array::PrimitiveArray;
use arrow2::datatypes::DataType;

let a = PrimitiveArray::from([Some(999_99i128), Some(1_00i128), None, Some(2_00i128)]).to(DataType::Decimal(5, 2));
let b = PrimitiveArray::from([Some(10_00i128), Some(2_00i128), None, Some(2_00i128)]).to(DataType::Decimal(5, 2));

let result = checked_mul(&a, &b);
let expected = PrimitiveArray::from([None, Some(2_00i128), None, Some(4_00i128)]).to(DataType::Decimal(5, 2));

assert_eq!(result, expected);