Skip to main content

fp_mul_i

Function fp_mul_i 

Source
pub fn fp_mul_i(a: i128, b: i128) -> Result<i128, SolMathError>
Expand description

Signed fixed-point multiply: (a * b) / SCALE.

Both a and b are i128 values at SCALE (1e12). Returns the product at SCALE. Exact (truncation toward zero).

Returns Err(Overflow) if the result exceeds i128 range.

ยงExample

use solmath::{fp_mul_i, SCALE_I};
let result = fp_mul_i(-2 * SCALE_I, 3 * SCALE_I).unwrap();
assert_eq!(result, -6 * SCALE_I);