diff options
author | Koala Zen <koala@zen.net> | 2015-05-06 12:37:15 -0700 |
---|---|---|
committer | Koala Zen <koala@zen.net> | 2015-05-06 12:37:15 -0700 |
commit | cf68d926d89a806e9921ddc69ba813d953d4de11 (patch) | |
tree | f0e706b880f4bfdc27086057026fdaef7626cbec | |
parent | b9e02b1efc14a309e613ec4d4cf8c793503bc797 (diff) | |
download | Nim-cf68d926d89a806e9921ddc69ba813d953d4de11.tar.gz |
fixes isPowerOfTwo returning true on the smallest integer
-rw-r--r-- | lib/pure/math.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/math.nim b/lib/pure/math.nim index daa108460..a5013a3ad 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -85,7 +85,7 @@ proc fac*(n: int): int {.noSideEffect.} = proc isPowerOfTwo*(x: int): bool {.noSideEffect.} = ## returns true, if `x` is a power of two, false otherwise. ## Zero and negative numbers are not a power of two. - return (x != 0) and ((x and (x - 1)) == 0) + return (x > 0) and ((x and (x - 1)) == 0) proc nextPowerOfTwo*(x: int): int {.noSideEffect.} = ## returns `x` rounded up to the nearest power of two. |