locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
14 lines (13 loc) • 438 B
JavaScript
export function log2(x) {
// discuss at: https://locutus.io/python/log2/
// parity verified: Python 3.12
// original by: Kevin van Zonneveld (https://kvz.io)
// note 1: Returns the base-2 logarithm of x
// example 1: log2(1)
// returns 1: 0
// example 2: log2(2)
// returns 2: 1
// example 3: log2(8)
// returns 3: 3
return Math.log2(x);
}