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

Documentation #73

Merged
merged 21 commits into from
Jun 7, 2024
Merged

Documentation #73

merged 21 commits into from
Jun 7, 2024

Conversation

scriptandcompile
Copy link
Contributor

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.

Copy link
Owner

@alexfertel alexfertel left a 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!

Comment on lines 625 to 628
// `((x | (x - 1)) + 1) & x == 0`
//
// Also `((x & -x) + x) & x == 0`

Copy link
Owner

@alexfertel alexfertel Jun 7, 2024

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);
Copy link
Owner

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.
@scriptandcompile
Copy link
Contributor Author

That should fix the issues! =D

Copy link
Owner

@alexfertel alexfertel left a 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!

@alexfertel alexfertel merged commit 03c3b43 into alexfertel:main Jun 7, 2024
3 checks passed
@scriptandcompile scriptandcompile deleted the documentation branch June 13, 2024 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants