Skip to content
Advertisement

Tag: bit-manipulation

Java storing two ints in a long

I want to store two ints in a long (instead of having to create a new Point object every time). Currently, I tried this. It’s not working, but I don’t know what is wrong with it: And I’m getting the int values like so: Answer y is getting sign-extended in the first snippet, which would overwrite x with -1 whenever

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: work (copied from HashMap). I can’t imagine how Integers, Longs or whatever

Advertisement