示例#1
0
 public static UnsignedShort fromBytes(byte[] c, int idx) {
   UnsignedShort number = new UnsignedShort();
   if ((c.length - idx) < 2) {
     throw new IllegalArgumentException("An UnsignedShort number is composed of 2 bytes.");
   }
   number.value = ((c[0] << 8) | (c[1] & 0xFFFF));
   return number;
 }
示例#2
0
 public static UnsignedShort fromString(String c, int radix) {
   UnsignedShort number = new UnsignedShort();
   long v = Integer.parseInt(c, radix);
   number.value = (int) (v & 0xFFFF);
   return number;
 }