Skip to content

Conversation

Rudra2637
Copy link
Contributor

Description of Change

Updated the countBitsFlip function to improve type safety and correctness:

  • Changed the input parameter from int64_t to uint64_t to ensure only non-negative numbers are allowed.
  • Changed the internal counter variable count from int to uint64_t to match the return type and prevent any theoretical overflow.
  • Maintains original functionality for normal inputs.

This ensures the function is consistent, safe, and fully aligned with the intended use of counting set bits in non-negative integers.


Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:
Improves type safety for countBitsFlip function without changing its behavior for normal inputs.

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.

1 participant