summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2019-11-04 15:02:36 +0100
committerGitHub <noreply@github.com>2019-11-04 15:02:36 +0100
commitae32d637f7f6a590d8cd1b825df004359999bb90 (patch)
treef9d9b7aef80dd33c66059436318e4822a2047fff /lib/system
parent992f0a775635e4d4e1c9b4800a676a693695d88c (diff)
downloadNim-ae32d637f7f6a590d8cd1b825df004359999bb90.tar.gz
[backport] fix #12395 (#12590)
'countBits32' is now fixed in the same way that
'countBits64' was already patched earlier (by adding 'u32
where needed).
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/sets.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/system/sets.nim b/lib/system/sets.nim
index 39f7d474f..fe414dac7 100644
--- a/lib/system/sets.nim
+++ b/lib/system/sets.nim
@@ -17,9 +17,9 @@ type
 proc countBits32(n: uint32): int {.compilerproc.} =
   # generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
   var v = uint32(n)
-  v = v - ((v shr 1) and 0x55555555)
-  v = (v and 0x33333333) + ((v shr 2) and 0x33333333)
-  result = (((v + (v shr 4) and 0xF0F0F0F) * 0x1010101) shr 24).int
+  v = v - ((v shr 1'u32) and 0x55555555'u32)
+  v = (v and 0x33333333'u32) + ((v shr 2'u32) and 0x33333333'u32)
+  result = (((v + (v shr 4'u32) and 0xF0F0F0F'u32) * 0x1010101) shr 24'u32).int
 
 proc countBits64(n: uint64): int {.compilerproc, inline.} =
   # generic formula is from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel