-
Notifications
You must be signed in to change notification settings - Fork 76
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
Documentation #73
Documentation #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! ❤️
Besides the is_power_of_two_difference
, everything looks good!
src/bit_manipulation/basic.rs
Outdated
// `((x | (x - 1)) + 1) & x == 0` | ||
// | ||
// Also `((x & -x) + x) & x == 0` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, it would be weird to leave these comments here, right?
Regarding is_power_of_two_difference
, it wasn't really clear here, but this function doesn't check if a number is a power of two, but instead if it is the difference of two powers of two.
Namely 2^k - 2^j
.
If it's not clear lmk and I'll expand a bit more on this.
pub fn multiply_signed(a: i8, b: i8) -> i8 { | ||
println!("{} {}", a, b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…correctly match the function instead of saying it is checking for a power of two in a different way.
That should fix the issues! =D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
I rewrote the docs for that function -- it should be easy to understand now.
I also removed the duplicated tests, since you added doctests. Good job!
Added documentation in the bit_manipulation/basic.rs section.
I've added both module documentation as well as documentation for all functions in the module:
get_bit, set_bit, clear_bit, update_bit, is_even, is_positive, multiply_by_two, divide_by_two, twos_complement, multiply_signed, multiply_unsigned, count_ones, bit_equivalence, bit_distance, is_power_of_two, is_power_of_two_difference, rightmost_one, and rightmost_zero.
I'm a bit concerned about
is_power_of_two_difference
, I think it might not be correctly detecting values. I have not changed the actual code though.