From 65f780cdcff14da4c3214fe9ed597c3f8629c923 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 16 Jan 2019 01:07:38 +0100 Subject: add log2 --- internal/hash/hash_log2.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 internal/hash/hash_log2.go (limited to 'internal/hash/hash_log2.go') 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 +} -- cgit v1.2.3