We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa9ceba commit 080f6f2Copy full SHA for 080f6f2
src/float.rs
@@ -5,7 +5,7 @@ use core::num::FpCategory;
5
use core::f32;
6
use core::f64;
7
8
-use {Num, NumCast};
+use {Num, NumCast, ToPrimitive};
9
10
/// Generic trait for floating point numbers that works with `no_std`.
11
///
@@ -668,7 +668,9 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
668
self = self.recip();
669
}
670
// It should always be possible to convert a positive `i32` to a `usize`.
671
- super::pow(self, exp as u32 as usize)
+ // Note, `i32::MIN` will wrap and still be negative, so we need to convert
672
+ // to `u32` without sign-extension before growing to `usize`.
673
+ super::pow(self, (exp as u32).to_usize().unwrap())
674
675
676
/// Converts to degrees, assuming the number is in radians.
0 commit comments