docs: private final BigDecimal getDecimal0(final int begin, final int intg, final int frac, final int intg0,
                                           final int frac0, final int intg0x, final int frac0x) {
          final int mask = ((buffer[begin] & 0x80) == 0x80) ? 0 : -1;
          int from = begin;
  
          /* max string length */
          final int len = ((mask != 0) ? 1 : 0) + ((intg != 0) ? intg : 1) // NL
                          + ((frac != 0) ? 1 : 0) + frac;
          char[] buf = new char[len];
          int pos = 0;
  
          if (mask != 0) /* decimal sign */
          buf[pos++] = ('-');
  
          final byte[] d_copy = buffer;
          d_copy[begin] ^= 0x80; /* clear sign */
          int mark = pos;
  
          if (intg0x != 0) {
              final int i = dig2bytes[intg0x];
              int x = 0;
              switch (i) {
                  case 1:
                      x = d_copy[from] /* one byte */;
                      break;
                  case 2:
                      x = getInt16BE(d_copy, from);
                      break;
                  case 3:
                      x = getInt24BE(d_copy, from);
                      break;
                  case 4:
                      x = getInt32BE(d_copy, from);
                      break;
              }
              from += i;
              x ^= mask;
              if (x < 0 || x >= powers10[intg0x + 1]) {
                  throw new IllegalArgumentException("bad format, x exceed: " + x + ", " + powers10[intg0x + 1]);
              }
              if (x != 0 /* !digit || x != 0 */) {
                  for (int j = intg0x; j > 0; j--) {
                      final int divisor = powers10[j - 1];
                      final int y = x / divisor;
                      if (mark < pos || y != 0) {
                          buf[pos++] = ((char) ('0' + y));
                      }
                      x -= y * divisor;
                  }
              }
          }
  
          for (final int stop = from + intg0 * SIZE_OF_INT32; from < stop; from += SIZE_OF_INT32) {
              int x = getInt32BE(d_copy, from);
              x ^= mask;
              if (x < 0 || x > DIG_MAX) {
                  throw new IllegalArgumentException("bad format, x exceed: " + x + ", " + DIG_MAX);
              }
              if (x != 0) {
                  if (mark < pos) {
                      for (int i = DIG_PER_DEC1; i > 0; i--) {
                          final int divisor = powers10[i - 1];
                          final int y = x / divisor;
                          buf[pos++] = ((char) ('0' + y));
                          x -= y * divisor;
                      }
                  } else {
                      for (int i = DIG_PER_DEC1; i > 0; i--) {
                          final int divisor = powers10[i - 1];
                          final int y = x / divisor;
                          if (mark < pos || y != 0) {
                              buf[pos++] = ((char) ('0' + y));
                          }
                          x -= y * divisor;
                      }
                  }
              } else if (mark < pos) {
                  for (int i = DIG_PER_DEC1; i > 0; i--)
                      buf[pos++] = ('0');
              }
          }
  
          if (mark == pos)
          /* fix 0.0 problem, only '.' may cause BigDecimal parsing exception. */
          buf[pos++] = ('0');
  
          if (frac > 0) {
              buf[pos++] = ('.');
              mark = pos;
  
              for (final int stop = from + frac0 * SIZE_OF_INT32; from < stop; from += SIZE_OF_INT32) {
                  int x = getInt32BE(d_copy, from);
                  x ^= mask;
                  if (x < 0 || x > DIG_MAX) {
                      throw new IllegalArgumentException("bad format, x exceed: " + x + ", " + DIG_MAX);
                  }
                  if (x != 0) {
                      for (int i = DIG_PER_DEC1; i > 0; i--) {
                          final int divisor = powers10[i - 1];
                          final int y = x / divisor;
                          buf[pos++] = ((char) ('0' + y));
                          x -= y * divisor;
                      }
                  } else {
                      for (int i = DIG_PER_DEC1; i > 0; i--)
                          buf[pos++] = ('0');
                  }
              }
  
              if (frac0x != 0) {
                  final int i = dig2bytes[frac0x];
                  int x = 0;
                  switch (i) {
                      case 1:
                          x = d_copy[from] /* one byte */;
                          break;
                      case 2:
                          x = getInt16BE(d_copy, from);
                          break;
                      case 3:
                          x = getInt24BE(d_copy, from);
                          break;
                      case 4:
                          x = getInt32BE(d_copy, from);
                          break;
                  }
                  x ^= mask;
                  if (x != 0) {
                      final int dig = DIG_PER_DEC1 - frac0x;
                      x *= powers10[dig];
                      if (x < 0 || x > DIG_MAX) {
                          throw new IllegalArgumentException("bad format, x exceed: " + x + ", " + DIG_MAX);
                      }
                      for (int j = DIG_PER_DEC1; j > dig; j--) {
                          final int divisor = powers10[j - 1];
                          final int y = x / divisor;
                          buf[pos++] = ((char) ('0' + y));
                          x -= y * divisor;
                      }
                  }
              }
  
              if (mark == pos)
              /* make number more friendly */
              buf[pos++] = ('0');
          }
  
          d_copy[begin] ^= 0x80; /* restore sign */
          String decimal = String.valueOf(buf, 0, pos);
          return new BigDecimal(decimal);
      }
  
      /**
       * Fill MY_BITMAP structure from buffer.
       * 
       * @param len The length of MY_BITMAP in bits.
       */
      public final void fillBitmap(BitSet bitmap, final int pos, final int len) {
          if (pos + ((len + 7) / 8) > limit || pos < 0) throw new IllegalArgumentException("limit excceed: "
                                                                                           + (pos + (len + 7) / 8));
  
          fillBitmap0(bitmap, origin + pos, len);
      }
  
      /**
       * Fill next MY_BITMAP structure from buffer.
       * 
       * @param len The length of MY_BITMAP in bits.
       */
      public final void fillBitmap(BitSet bitmap, final int len) {
          if (position + ((len + 7) / 8) > origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                                              + (position
                                                                                                 + ((len + 7) / 8) - origin));
  
          position = fillBitmap0(bitmap, position, len);
      }
  
      /**
       * Fill MY_BITMAP structure from buffer.
       * 
       * @param len The length of MY_BITMAP in bits.
       */
      private final int fillBitmap0(BitSet bitmap, int pos, final int len) {
          final byte[] buf = buffer;
  
          for (int bit = 0; bit < len; bit += 8) {
              int flag = ((int) buf[pos++]) & 0xff;
              if (flag == 0) {
                  continue;
              }
              if ((flag & 0x01) != 0) bitmap.set(bit);
              if ((flag & 0x02) != 0) bitmap.set(bit + 1);
              if ((flag & 0x04) != 0) bitmap.set(bit + 2);
              if ((flag & 0x08) != 0) bitmap.set(bit + 3);
              if ((flag & 0x10) != 0) bitmap.set(bit + 4);
              if ((flag & 0x20) != 0) bitmap.set(bit + 5);
              if ((flag & 0x40) != 0) bitmap.set(bit + 6);
              if ((flag & 0x80) != 0) bitmap.set(bit + 7);
          }
          return pos;
      }
  
      /**
       * Return MY_BITMAP structure from buffer.
       * 
       * @param len The length of MY_BITMAP in bits.
       */
      public final BitSet getBitmap(final int pos, final int len) {
          BitSet bitmap = new BitSet(len);
          fillBitmap(bitmap, pos, len);
          return bitmap;
      }
  
      /**
       * Return next MY_BITMAP structure from buffer.
       * 
       * @param len The length of MY_BITMAP in bits.
       */
      public final BitSet getBitmap(final int len) {
          BitSet bitmap = new BitSet(len);
          fillBitmap(bitmap, len);
          return bitmap;
      }
  
      /**
       * Fill n bytes into output stream.
       */
      public final void fillOutput(OutputStream out, final int pos, final int len) throws IOException {
          if (pos + len > limit || pos < 0) throw new IllegalArgumentException("limit excceed: " + (pos + len));
  
          out.write(buffer, origin + pos, len);
      }
  
      /**
       * Fill next n bytes into output stream.
       */
      public final void fillOutput(OutputStream out, final int len) throws IOException {
          if (position + len > origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                                  + (position + len - origin));
  
          out.write(buffer, position, len);
          position += len;
      }
  
      /**
       * Fill n bytes in this buffer.
       */
      public final void fillBytes(final int pos, byte[] dest, final int destPos, final int len) {
          if (pos + len > limit || pos < 0) throw new IllegalArgumentException("limit excceed: " + (pos + len));
  
          System.arraycopy(buffer, origin + pos, dest, destPos, len);
      }
  
      /**
       * Fill next n bytes in this buffer.
       */
      public final void fillBytes(byte[] dest, final int destPos, final int len) {
          if (position + len > origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                                  + (position + len - origin));
  
          System.arraycopy(buffer, position, dest, destPos, len);
          position += len;
      }
  
      /**
       * Return n-byte data from buffer.
       */
      public final byte[] getData(final int pos, final int len) {
          byte[] buf = new byte[len];
          fillBytes(pos, buf, 0, len);
          return buf;
      }
  
      /**
       * Return next n-byte data from buffer.
       */
      public final byte[] getData(final int len) {
          byte[] buf = new byte[len];
          fillBytes(buf, 0, len);
          return buf;
      }
  
      /**
       * Return all remaining data from buffer.
       */
      public final byte[] getData() {
          return getData(0, limit);
      }
  
      /**
       * Return full hexdump from position.
       */
      public final String hexdump(final int pos) {
          if ((limit - pos) > 0) {
              final int begin = origin + pos;
              final int end = origin + limit;
  
              byte[] buf = buffer;
              StringBuilder dump = new StringBuilder();
              dump.append(Integer.toHexString(buf[begin] >> 4));
              dump.append(Integer.toHexString(buf[begin] & 0xf));
              for (int i = begin + 1; i < end; i++) {
                  dump.append("_");
                  dump.append(Integer.toHexString(buf[i] >> 4));
                  dump.append(Integer.toHexString(buf[i] & 0xf));
              }
  
              return dump.toString();
          }
          return "";
      }
  
      /**
       * Return hexdump from position, for len bytes.
       */
      public final String hexdump(final int pos, final int len) {
          if ((limit - pos) > 0) {
              final int begin = origin + pos;
              final int end = Math.min(begin + len, origin + limit);
  
              byte[] buf = buffer;
              StringBuilder dump = new StringBuilder();
              dump.append(Integer.toHexString(buf[begin] >> 4));
              dump.append(Integer.toHexString(buf[begin] & 0xf));
              for (int i = begin + 1; i < end; i++) {
                  dump.append("_");
                  dump.append(Integer.toHexString(buf[i] >> 4));
                  dump.append(Integer.toHexString(buf[i] & 0xf));
              }
  
              return dump.toString();
          }
          return "";
      }
  }