diff options
author | Andreas Rumpf <andreasrumpf@noname> | 2009-09-15 23:22:22 +0200 |
---|---|---|
committer | Andreas Rumpf <andreasrumpf@noname> | 2009-09-15 23:22:22 +0200 |
commit | 66a7e3d37c0303997a6b1a3b7ec263dfb8c07748 (patch) | |
tree | 40ae1ab8aeb9086b7310ea73ab8a2ed6b597f88b /lib/system/cntbits.nim | |
parent | 300430fbba28b408f7ac86ca46b03d9d50839399 (diff) | |
download | Nim-66a7e3d37c0303997a6b1a3b7ec263dfb8c07748.tar.gz |
added tools and web dirs
Diffstat (limited to 'lib/system/cntbits.nim')
-rwxr-xr-x[-rw-r--r--] | lib/system/cntbits.nim | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/lib/system/cntbits.nim b/lib/system/cntbits.nim index a975f38ae..281b96dd0 100644..100755 --- a/lib/system/cntbits.nim +++ b/lib/system/cntbits.nim @@ -8,13 +8,5 @@ # -proc population16(a: int): int {.inline.} = - var x = a - x = ((x and 0xAAAA) shr 1) + (x and 0x5555) - x = ((x and 0xCCCC) shr 2) + (x and 0x3333) - x = ((x and 0xF0F0) shr 4) + (x and 0x0F0F) - x = ((x and 0xFF00) shr 8) + (x and 0x00FF) - return x -proc countBits(n: int32): int = - result = population16(n and 0xffff'i32) + population16(n shr 16'i32) + |