Open martinvuyk opened 4 months ago
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.
Review Mojo's priorities
What is your request?
Rename
bit_ceil
andbit_floor
toclosest_pow_2_ge
andclosest_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 forbit_ceil
What is your motivation for this change?
Verbose names in exchange for clarity. Also, extending the naming to include
closest_pow_2_gt
andclosest_pow_2_lt
becomes clear and simple.Any other details?
No response