pub trait FixedPowI: Fixed {
// Required method
fn powi(self, n: i32) -> Self;
}
Expand description
Extension trait providing integer exponentiation for fixed-point numbers.
Required Methods§
Sourcefn powi(self, n: i32) -> Self
fn powi(self, n: i32) -> Self
Raises a number to an integer power, using exponentiation by squaring.
Using this function is generally faster than using powf
.
§Panics
Panics if 1
cannot be represented in Self
, and n
is non-positive.
§Examples
use fixed::types::I32F32;
use fixed_exp::FixedPowI;
let x = I32F32::from_num(4.0);
assert_eq!(I32F32::from_num(1024.0), x.powi(5));
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.