-
Notifications
You must be signed in to change notification settings - Fork 20.8k
Add Power of Four Check using bit manipulation #7065
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
Add Power of Four Check using bit manipulation #7065
Conversation
- Implements isPowerOfFour method using bit manipulation - Checks if number is power of two and has bit at even position - Includes comprehensive unit tests - Fixes TheAlgorithms#6940
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7065 +/- ##
============================================
- Coverage 78.36% 78.35% -0.02%
- Complexity 6684 6689 +5
============================================
Files 755 756 +1
Lines 22203 22208 +5
Branches 4360 4363 +3
============================================
+ Hits 17400 17401 +1
- Misses 4105 4107 +2
- Partials 698 700 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@DenizAltunkapan could please you look into the pr sir!i have already once contributed one pr . |
|
@krishna-medapati could you please do me the favor and assure that your implemented classes are in the same package as the existing power of two class? https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/maths/PowerOfTwoOrNot.java |
@DenizAltunkapan Done! I've successfully moved both PowerOfFour classes to the com.thealgorithms.maths package to match the PowerOfTwoOrNot class location. All tests are passing and all checks are green. Ready for final review. Thank you . |
Fixes #6940
Description
Added a utility class to check if a number is a power of four using efficient bit manipulation.
Implementation Details
(n & (n-1)) == 00x55555555Changes Made
PowerOfFour.javawithisPowerOfFour()methodPowerOfFourTest.javaTesting
All test cases pass: