From a8c3c45fafb24153daf566bb0dc55858c6838150 Mon Sep 17 00:00:00 2001 From: Dean Eigenmann Date: Fri, 22 Feb 2019 12:58:59 +0100 Subject: [PATCH 1/2] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 0556f3178..f7aa1c6d7 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1028,10 +1028,7 @@ def is_power_of_two(value: int) -> bool: """ Check if ``value`` is a power of two integer. """ - if value == 0: - return False - else: - return 2**int(math.log2(value)) == value + return (value > 0) && (value & (value - 1) == 0) ``` ### `int_to_bytes1`, `int_to_bytes2`, ... From e1fc8a5765eb225f1c3485935b63a6c6bef3f5d4 Mon Sep 17 00:00:00 2001 From: Dean Eigenmann Date: Fri, 22 Feb 2019 13:00:29 +0100 Subject: [PATCH 2/2] Update 0_beacon-chain.md --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index f7aa1c6d7..5c6718137 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1028,7 +1028,7 @@ def is_power_of_two(value: int) -> bool: """ Check if ``value`` is a power of two integer. """ - return (value > 0) && (value & (value - 1) == 0) + return (value > 0) and (value & (value - 1) == 0) ``` ### `int_to_bytes1`, `int_to_bytes2`, ...