aboutsummaryrefslogtreecommitdiff
path: root/internal/hash/hash_log2.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-01-16 01:07:38 +0100
committerDimitri Sokolyuk <demon@dim13.org>2019-01-16 01:07:38 +0100
commitba25b16a8182e291b6bcc6e4c230a5178ee21ae8 (patch)
tree40eab63a22778b98e9b7323208e641e72aaa47d0 /internal/hash/hash_log2.go
parent2603c5fa0799be938ce2979ac01ea72d7b9b6304 (diff)
add log2
Diffstat (limited to 'internal/hash/hash_log2.go')
-rw-r--r--internal/hash/hash_log2.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/hash/hash_log2.go b/internal/hash/hash_log2.go
new file mode 100644
index 0000000..5e30f17
--- /dev/null
+++ b/internal/hash/hash_log2.go
@@ -0,0 +1,9 @@
+package hash
+
+func log2(num uint32) uint32 {
+ var i uint32
+ for limit := uint32(1); limit < num; limit <<= 1 {
+ i++
+ }
+ return i
+}