Skip to content

Commit

Permalink
Remove next pow of two util func.
Browse files Browse the repository at this point in the history
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/starkware-libs/stwo/465)
<!-- Reviewable:end -->
  • Loading branch information
shaharsamocha7 authored Mar 13, 2024
1 parent 3658aa0 commit 252ebc8
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/math/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ pub fn log2_floor(n: usize) -> usize {
num_of_bits - n.leading_zeros() as usize - 1
}

#[inline]
pub fn next_pow_two(n: usize) -> usize {
2_usize.pow(log2_ceil(n) as u32)
}

#[inline]
pub fn prev_pow_two(n: usize) -> usize {
2_usize.pow(log2_floor(n) as u32)
Expand Down Expand Up @@ -52,9 +47,7 @@ pub fn egcd(x: isize, y: isize) -> (isize, isize, isize) {

#[cfg(test)]
mod tests {
use crate::math::utils::{
egcd, log2_ceil, log2_floor, next_pow_two, prev_pow_two, usize_div_ceil,
};
use crate::math::utils::{egcd, log2_ceil, log2_floor, prev_pow_two, usize_div_ceil};

#[test]
fn log2_ceil_test() {
Expand All @@ -72,13 +65,6 @@ mod tests {
assert_eq!(log2_floor(65), 6);
}

#[test]
fn next_power_of_two_test() {
assert_eq!(next_pow_two(1), 1);
assert_eq!(next_pow_two(2), 2);
assert_eq!(next_pow_two(3), 4);
}

#[test]
fn prev_power_of_two_test() {
assert_eq!(prev_pow_two(1), 1);
Expand Down

0 comments on commit 252ebc8

Please sign in to comment.