Skip to content

prevPow2

Subhajit Sahu edited this page Jun 7, 2020 · 9 revisions

Gets previous power-of-2. 🏃 [:vhs:] 📦 🌔 📒

Similar: log2, pow2, isPow2, nextPow2.

integer.prevPow2(x);
// x: an int32
const integer = require('extra-integer');

integer.prevPow2(63);
// 32

integer.prevPow2(128);
// 128

integer.prevPow2(1);
// 1

references

Clone this wiki locally