BigDecimal bit manipulation in java

bigdecimal, java

Solution

As the name suggests, a `BigDecimal` is stored in decimal representation. So the quickest way to divide by powers of 2 is ... to divide by powers of two. You can shift-left and shift-right, but only in base-10 (and even then it behaves differently from bit-shifts, because it can produce non-integer values).

Problem

Does BigDecimal support bit manipulation? If yes, can someone please point to a good tutorial on this? If no, what is the best method to divide a BigDecimal variable by powers of 2?

Original source