pub trait Pow<Exp> {
    type Output;
    fn powi(self, exp: Exp) -> Self::Output;
}
Expand description

A type operator that provides exponentiation by repeated squaring.

Example

use typenum::{Integer, Pow, N3, P3};

assert_eq!(<N3 as Pow<P3>>::Output::to_i32(), -27);

Associated Types

The result of the exponentiation.

Required methods

This function isn’t used in this crate, but may be useful for others. It is implemented for primitives.

Example
use typenum::{Pow, U3};

let a = 7u32.powi(U3::new());
let b = 7u32.pow(3);
assert_eq!(a, b);

let x = 3.0.powi(U3::new());
let y = 27.0;
assert_eq!(x, y);

Implementations on Foreign Types

Implementors

0^0 = 1

0^N = 0

1^N = 1

0^P = 0

N^0 = 1

P^0 = 1

(-1)^N = 1 if N is even

(-1)^N = -1 if N is odd

P(Ul)^P(Ur) = P(Ul^Ur)

N(Ul)^P(Ur) = P(Ul^Ur) if Ur is even

N(Ul)^P(Ur) = N(Ul^Ur) if Ur is odd

X^N