diff --git a/library/core/benches/num/int_log/mod.rs b/library/core/benches/num/int_log/mod.rs index 542a0a0ca08..6a219bcdd55 100644 --- a/library/core/benches/num/int_log/mod.rs +++ b/library/core/benches/num/int_log/mod.rs @@ -1,5 +1,3 @@ -#![feature(int_log)] - use rand::Rng; use test::{black_box, Bencher}; diff --git a/library/core/src/num/int_log10.rs b/library/core/src/num/int_log10.rs index d28552cf4aa..398bb07a07e 100644 --- a/library/core/src/num/int_log10.rs +++ b/library/core/src/num/int_log10.rs @@ -7,16 +7,16 @@ mod unchecked { // in the bits above the low 8 bits. // Adding c1 to val gives 10 in the top bits for val < 10, 11 for val >= 10 - let c1 = 0b11_00000000 - 10; // 758 + const C1: u32 = 0b11_00000000 - 10; // 758 // Adding c2 to val gives 01 in the top bits for val < 100, 10 for val >= 100 - let c2 = 0b10_00000000 - 100; // 412 + const C2: u32 = 0b10_00000000 - 100; // 412 // Value of top bits: // +c1 +c2 1&2 // 0..=9 10 01 00 = 0 // 10..=99 11 01 01 = 1 // 100..=255 11 10 10 = 2 - ((val + c1) & (val + c2)) >> 8 + ((val + C1) & (val + C2)) >> 8 } // 0 < val < 100_000 @@ -24,10 +24,10 @@ mod unchecked { // Similar to u8, when adding one of these constants to val, // we get two possible bit patterns above the low 17 bits, // depending on whether val is below or above the threshold. - let c1 = 0b011_00000000000000000 - 10; // 393206 - let c2 = 0b100_00000000000000000 - 100; // 524188 - let c3 = 0b111_00000000000000000 - 1000; // 916504 - let c4 = 0b100_00000000000000000 - 10000; // 514288 + const C1: u32 = 0b011_00000000000000000 - 10; // 393206 + const C2: u32 = 0b100_00000000000000000 - 100; // 524188 + const C3: u32 = 0b111_00000000000000000 - 1000; // 916504 + const C4: u32 = 0b100_00000000000000000 - 10000; // 514288 // Value of top bits: // +c1 +c2 1&2 +c3 +c4 3&4 ^ @@ -36,7 +36,7 @@ mod unchecked { // 100..=999 011 100 000 110 011 010 010 = 2 // 1000..=9999 011 100 000 111 011 011 011 = 3 // 10000..=99999 011 100 000 111 100 100 100 = 4 - (((val + c1) & (val + c2)) ^ ((val + c3) & (val + c4))) >> 17 + (((val + C1) & (val + C2)) ^ ((val + C3) & (val + C4))) >> 17 } // 0 < val <= u16::MAX