Skip to content
Subhajit Sahu edited this page Feb 2, 2021 · 12 revisions

Rotates bits. 🏃 📼 📦 🌔 📒

Similar: rotate, reverse.


bit.rotate(x, [n]);
// x: an int32
// n: rotate amount (+ve: left, -ve: right)
const bit = require("extra-bit");

bit.rotate(0x11112222, 4);
// 286401057 (0x11122221)

bit.rotate(0x11112222, -4);
// 554766882 (0x21111222)


References

Clone this wiki locally