Commons Lang、BitField#getShortRawValue(), #getShortValue()
import org.apache.commons.lang.BitField; public class C2009042600 { public static void main(String[] args) { BitField bf; bf = new BitField(5); System.out.println(bf.getShortRawValue((short)15) + " " + bf.getShortValue((short)15)); bf = new BitField(4); System.out.println(bf.getShortRawValue((short)15) + " " + bf.getShortValue((short)15)); } }
で、
5 5 4 1