Skip to content
Advertisement

Bit twiddling for Java or Scala programmers

Does anyone know of good tutorials or even a good book to master bit-level operations? I mean it’s almost clear what every operation does (in Java for instance) or where to find the right documentation, but I’m very new to this topic and I wonder how things like:

JavaScript

work (copied from HashMap). I can’t imagine how Integers, Longs or whatever data type are affected by bit operations 🙁

I mean I don’t want to know every kind of operation, just what seems to be fundamental to high level programmers in Java or Scala like the example provided.

Another example would be:

JavaScript

That just seems to be magic 🙁

Advertisement

Answer

To understand the basics, you need to understand how data is represented. This requires understanding binary and usually two’s complement.

Once you understand the basics, a lot of useful hacks can be found at the ubiquitous Stanford source.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement