diff options
author | Varriount <Varriount@users.noreply.github.com> | 2015-05-07 12:54:37 -0400 |
---|---|---|
committer | Varriount <Varriount@users.noreply.github.com> | 2015-05-07 12:54:37 -0400 |
commit | d8827188826ebecda132160c2992959cb045d37e (patch) | |
tree | ac0861fd4977050e8c88a9745805a66456cc0a82 /lib | |
parent | b5e06c09736df94b31c083971cee90edb6364450 (diff) | |
parent | cf68d926d89a806e9921ddc69ba813d953d4de11 (diff) | |
download | Nim-d8827188826ebecda132160c2992959cb045d37e.tar.gz |
Merge pull request #2665 from koalazen/fix_math_is_power_of_two
fixes isPowerOfTwo returning true on the smallest integer
Diffstat (limited to 'lib')
-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. |