algorithm: Log2 using bitwise operations (#1132)

This commit is contained in:
acarlson
2022-10-09 08:06:23 -04:00
committed by GitHub
parent 56713e8f43
commit 78f023fdd1
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import { logTwo } from '../LogTwo'
for (let i = 1; i < 100; i++) {
test('log2(' + i + ')', () => {
expect(logTwo(i)).toBe(Math.floor(Math.log2(i)))
})
}