This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* moved function * updated
- Loading branch information
Dean Eigenmann
authored
Feb 22, 2019
1 parent
921fbd3
commit 954bcb6
Showing
4 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
extension Int { | ||
|
||
func isPowerOfTwo() -> Bool { | ||
return (self > 0) && (self & (self - 1) == 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import XCTest | ||
@testable import BeaconChain | ||
|
||
final class IntTests: XCTestCase { | ||
|
||
func testIsPowerOfTwo() { | ||
XCTAssertTrue(4.isPowerOfTwo()) | ||
XCTAssertFalse(3.isPowerOfTwo()) | ||
} | ||
} |