summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKoala Zen <koala@zen.net>2015-05-06 12:37:15 -0700
committerKoala Zen <koala@zen.net>2015-05-06 12:37:15 -0700
commitcf68d926d89a806e9921ddc69ba813d953d4de11 (patch)
treef0e706b880f4bfdc27086057026fdaef7626cbec
parentb9e02b1efc14a309e613ec4d4cf8c793503bc797 (diff)
downloadNim-cf68d926d89a806e9921ddc69ba813d953d4de11.tar.gz
fixes isPowerOfTwo returning true on the smallest integer
-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.