diff --git a/src/pow.rs b/src/pow.rs index 7ef8d3f..daecb8e 100644 --- a/src/pow.rs +++ b/src/pow.rs @@ -173,6 +173,8 @@ mod float_impls { /// Raises a value to the power of exp, using exponentiation by squaring. /// +/// Note that `0⁰` (`pow(0, 0)`) returnes `1`. Mathematically this is undefined. +/// /// # Example /// /// ```rust @@ -180,6 +182,7 @@ mod float_impls { /// /// assert_eq!(pow(2i8, 4), 16); /// assert_eq!(pow(6u8, 3), 216); +/// assert_eq!(pow(0u8, 0), 1); // Be aware if this case affects you /// ``` #[inline] pub fn pow>(mut base: T, mut exp: usize) -> T { @@ -208,6 +211,8 @@ pub fn pow>(mut base: T, mut exp: usize) -> /// Raises a value to the power of exp, returning `None` if an overflow occurred. /// +/// Note that `0⁰` (`checked_pow(0, 0)`) returnes `Some(1)`. Mathematically this is undefined. +/// /// Otherwise same as the `pow` function. /// /// # Example @@ -218,6 +223,7 @@ pub fn pow>(mut base: T, mut exp: usize) -> /// assert_eq!(checked_pow(2i8, 4), Some(16)); /// assert_eq!(checked_pow(7i8, 8), None); /// assert_eq!(checked_pow(7u32, 8), Some(5_764_801)); +/// assert_eq!(checked_pow(0u32, 0), Some(1)); // Be aware if this case affect you /// ``` #[inline] pub fn checked_pow(mut base: T, mut exp: usize) -> Option {