Function fixed_powi

Source
fn fixed_powi<T>(x: T, n: i128) -> Option<T>
where T: FixedPointNumber + Copy,
Expand description

Raises a fixed-point number x to an integer power n using binary exponentiation.

§Behavior

CaseResult
n = 0Some(1) - x^0 = 1 always
n > 0Some(x^n)
n < 0, x != 0`Some(1 / x^
n < 0, x = 0None - division by zero

Uses saturating arithmetic throughout, so intermediate overflow clamps to the type’s maximum rather than wrapping or panicking. Returns None only for division-by-zero or when 1 / x^|n| is unrepresentable.

§Arguments

  • x - The fixed-point base.
  • n - The integer exponent, including i128::MIN.