Function fixed_powi_positive

Source
fn fixed_powi_positive<T>(x: T, n: u128) -> T
where T: FixedPointNumber + Copy,
Expand description

Core binary exponentiation for non-negative integer powers.

Computes x^n in O(log n) multiplications using the square-and-multiply algorithm. Extracted as a separate function so both the positive and negative paths of fixed_powi can share the same implementation.

Uses saturating arithmetic - intermediate overflow clamps to the type’s maximum rather than wrapping or panicking.

§Arguments

  • x - The fixed-point base.
  • n - The non-negative exponent as u128.