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

fix zero being power of two #1684

Merged
merged 1 commit into from
Feb 22, 2019
Merged

fix zero being power of two #1684

merged 1 commit into from
Feb 22, 2019

Conversation

prestonvanloon
Copy link
Member

@prestonvanloon prestonvanloon commented Feb 22, 2019

zero isn't a power of two

Verified inline with spec PR: ethereum/consensus-specs#674

@prestonvanloon prestonvanloon added the Ready For Review A pull request ready for code review label Feb 22, 2019
@@ -27,7 +27,7 @@ func CeilDiv8(n int) int {
// IsPowerOf2 returns true if n is an
// exact power of two. False otherwise.
func IsPowerOf2(n uint64) bool {
return (n & (n - 1)) == 0
return n != 0 && (n&(n-1)) == 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting was from gofmt so i guess this is the preferred spacing

@codecov
Copy link

codecov bot commented Feb 22, 2019

Codecov Report

Merging #1684 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1684      +/-   ##
==========================================
+ Coverage   70.79%   70.85%   +0.05%     
==========================================
  Files          97       97              
  Lines        6879     6879              
==========================================
+ Hits         4870     4874       +4     
+ Misses       1564     1561       -3     
+ Partials      445      444       -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants