Why bitwise operators, real-world use cases?
Studying the topic, bitwise operators.
Packing bit "masks" into integer values with different filters.
Hash / Crypt Functional.
Any simple overlay search with fuzzy matches (text, image, sound).Hannah Christensen
For example packing 32 values into a whole.Atticus Woodward
Practically speaking, convert a string to a number:
var a = '123';
a = ~~a;
console.log(typeof a); //number
Discard signs after period:
var b = 123.743932;
console.log( ~~b ); // 123Ruby Jefferson
Well, for example, you can read how the file type is stored in Unix (regular file, directory / directory, several types of special files) and attributes / access rights. To find out if the file has the required type, you need to do "AND 0b1111_000_000_000_000" (this number is in binary form; underscores are for my convenience) and compare with the code of the required type.
Here we see that bitwise operations allow working with parameters packed in several pieces into one integer.
Or here's an example of using bitwise operations: " Integer base 2 logarithm in O (1) " ...Anonymous
To place the code, please use CodePen or similar tool. Thanks you!