We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a3093a commit ad38f9bCopy full SHA for ad38f9b
core/src/num/uint_macros.rs
@@ -1093,9 +1093,12 @@ macro_rules! uint_impl {
1093
pub const fn checked_ilog(self, base: Self) -> Option<u32> {
1094
if self <= 0 || base <= 1 {
1095
None
1096
+ } else if self < base {
1097
+ Some(0)
1098
} else {
- let mut n = 0;
- let mut r = 1;
1099
+ // Since base >= self, n >= 1
1100
+ let mut n = 1;
1101
+ let mut r = base;
1102
1103
// Optimization for 128 bit wide integers.
1104
if Self::BITS == 128 {
0 commit comments