checkedMul (Function)

Signature: checkedMul(a: int, b: int) -> Result<int, Error>

Description: Integer multiplication that reports overflow instead of wrapping, returning Result<int, MathError>. The guarded sibling of *.

Parameters

  • a (int): The first factor
  • b (int): The second factor

Returns: Result<int, Error>

Example

let p = checkedMul(a: 6, b: 7) ?: 0  // 42
p = checkedMul (a: 6, b: 7) ?: 0  // 42