Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Rename bit_ceil and bit_floor to closest_pow_2_ge and closest_pow_2_le #3271

Open
1 task done
martinvuyk opened this issue Jul 18, 2024 · 1 comment
Open
1 task done
Labels
enhancement New feature or request mojo-repo Tag all issues with this label

Comments

@martinvuyk
Copy link
Contributor

Review Mojo's priorities

What is your request?

Rename bit_ceil and bit_floor to closest_pow_2_ge and closest_pow_2_le.

Similarly as issue #3158, I think some renaming would be fitting here. I know these names come from C++, but some verbosity and clearer use case is better when looking for something and not intuitively understanding what the function name means.

In my particular case, I literally reimplemented bit_ceil with bitshifting (100% copied from stack overflow) because I was looking for the closest power of two greater than or equal to a dynamic value. And I was literally writing the code to include in a PR when I read the code for bit_ceil

What is your motivation for this change?

Verbose names in exchange for clarity. Also, extending the naming to include closest_pow_2_gt and closest_pow_2_lt becomes clear and simple.

Any other details?

No response

@martinvuyk martinvuyk added enhancement New feature or request mojo-repo Tag all issues with this label labels Jul 18, 2024
Copy link
Collaborator

Thanks for filing the issue! We talked about this internally earlier this week and decided on the names: next_power_of_two and prev_power_of_two. This is taking inspiration from the Rust https://doc.rust-lang.org/std/primitive.usize.html#method.next_power_of_two.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants