summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorVarriount <Varriount@users.noreply.github.com>2015-05-07 12:54:37 -0400
committerVarriount <Varriount@users.noreply.github.com>2015-05-07 12:54:37 -0400
commitd8827188826ebecda132160c2992959cb045d37e (patch)
treeac0861fd4977050e8c88a9745805a66456cc0a82 /lib
parentb5e06c09736df94b31c083971cee90edb6364450 (diff)
parentcf68d926d89a806e9921ddc69ba813d953d4de11 (diff)
downloadNim-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.nim2
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.