Collapsing multiple ints into a long
Every now and then, you may want to collapse multiple values into a long, to use as a key for a Map, for example. The following code is an example of collapsing three ints into one long. Obvious care should be taken here: three ints don’t actually fit into one long, so the excess bits are just discarded. If we do this, we can afford to use the lowest 20 bits, plus the sign...
Aug 15, 2014 — 2 minute(s) read