code: public static byte safeIntToByte(int i) {
          if (i > (int)Byte.MAX_VALUE || i < (int) Byte.MIN_VALUE) {
              throw new IllegalStateException("Cannot convert int to byte: " + i);
          }
          return (byte)i;
      }
docs: /* ---- Convert 4-byte signed int to fewer bytes. -----