public static double parseDouble(final byte[] str, final int start, final int end) {
    if(start >= end) {
      throw EMPTY_STRING;
    }
    // Current position and character.
    int pos = start;
    byte cur = str[pos];

    // Match for NaN spellings
    if(matchNaN(str, cur, pos, end)) {
      return Double.NaN;
    }
    // Match sign
    boolean isNegative = (cur == '-');
    // Carefully consume the - character, update c and i:
    if((isNegative || (cur == '+')) && (++pos < end)) {
      cur = str[pos];
    }
    if(matchInf(str, cur, pos, end)) {
      return isNegative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
    }

    // Begin parsing real numbers!
    if(((cur < '0') || (cur > '9')) && (cur != '.')) {
      throw NOT_A_NUMBER;
    }

    // Parse digits into a long, remember offset of decimal point.
    long decimal = 0;
    int decimalPoint = -1;
    while(true) {
      final int digit = cur - '0';
      if((digit >= 0) && (digit <= 9)) {
        final long tmp = (decimal << 3) + (decimal << 1) + digit;
        if(tmp >= decimal) {
          decimal = tmp; // Otherwise, silently ignore the extra digits.
        }
        else if(++decimalPoint == 0) { // Because we ignored the digit
          throw PRECISION_OVERFLOW;
        }
      }
      else if((cur == '.') && (decimalPoint < 0)) {
        decimalPoint = pos;
      }
      else { // No more digits, or a second dot.
        break;
      }
      if(++pos >= end) {
        break;
      }
      cur = str[pos];
    }
    // We need the offset from the back for adjusting the exponent:
    // Note that we need the current value of i!
    decimalPoint = (decimalPoint >= 0) ? pos - decimalPoint - 1 : 0;

    // Reads exponent.
    int exp = 0;
    if((pos + 1 < end) && ((cur == 'E') || (cur == 'e'))) {
      cur = str[++pos];
      final boolean isNegativeExp = (cur == '-');
      if((isNegativeExp || (cur == '+')) && (++pos < end)) {
        cur = str[pos];
      }
      if((cur < '0') || (cur > '9')) { // At least one digit required.
        throw INVALID_EXPONENT;
      }
      while(true) {
        final int digit = cur - '0';
        if(digit < 0 || digit > 9) {
          break;
        }
        exp = (exp << 3) + (exp << 1) + digit;
        if(exp > Double.MAX_EXPONENT) {
          throw EXPONENT_OVERFLOW;
        }
        if(++pos >= end) {
          break;
        }
        cur = str[pos];
      }
      exp = isNegativeExp ? -exp : exp;
    }
    // Adjust exponent by the offset of the dot in our long.
    exp = decimalPoint > 0 ? (exp - decimalPoint) : exp;
    if(pos != end) {
      throw TRAILING_CHARACTERS;
    }

    return BitsUtil.lpow10(isNegative ? -decimal : decimal, exp);
  }
public static double parseDouble ( final byte [ ] str , final int start , final int end ) { if ( start >= end ) { throw EMPTY_STRING ; } int pos = start ; byte cur = str [ pos ] ; if ( matchNaN ( str , cur , pos , end ) ) { return Double . NaN ; } boolean isNegative = ( cur == '-' ) ; if ( ( isNegative || ( cur == '+' ) ) && ( ++ pos < end ) ) { cur = str [ pos ] ; } if ( matchInf ( str , cur , pos , end ) ) { return isNegative ? Double . NEGATIVE_INFINITY : Double . POSITIVE_INFINITY ; } if ( ( ( cur < '0' ) || ( cur > '9' ) ) && ( cur != '.' ) ) { throw NOT_A_NUMBER ; } long decimal = 0 ; int decimalPoint = - 1 ; while ( true ) { final int digit = cur - '0' ; if ( ( digit >= 0 ) && ( digit <= 9 ) ) { final long tmp = ( decimal << 3 ) + ( decimal << 1 ) + digit ; if ( tmp >= decimal ) { decimal = tmp ; } else if ( ++ decimalPoint == 0 ) { throw PRECISION_OVERFLOW ; } } else if ( ( cur == '.' ) && ( decimalPoint < 0 ) ) { decimalPoint = pos ; } else { break ; } if ( ++ pos >= end ) { break ; } cur = str [ pos ] ; } decimalPoint = ( decimalPoint >= 0 ) ? pos - decimalPoint - 1 : 0 ; int exp = 0 ; if ( ( pos + 1 < end ) && ( ( cur == 'E' ) || ( cur == 'e' ) ) ) { cur = str [ ++ pos ] ; final boolean isNegativeExp = ( cur == '-' ) ; if ( ( isNegativeExp || ( cur == '+' ) ) && ( ++ pos < end ) ) { cur = str [ pos ] ; } if ( ( cur < '0' ) || ( cur > '9' ) ) { throw INVALID_EXPONENT ; } while ( true ) { final int digit = cur - '0' ; if ( digit < 0 || digit > 9 ) { break ; } exp = ( exp << 3 ) + ( exp << 1 ) + digit ; if ( exp > Double . MAX_EXPONENT ) { throw EXPONENT_OVERFLOW ; } if ( ++ pos >= end ) { break ; } cur = str [ pos ] ; } exp = isNegativeExp ? - exp : exp ; } exp = decimalPoint > 0 ? ( exp - decimalPoint ) : exp ; if ( pos != end ) { throw TRAILING_CHARACTERS ; } return BitsUtil . lpow10 ( isNegative ? - decimal : decimal , exp ) ; }
Parse a double from a character sequence.

In contrast to Javas {@link Double#parseDouble}, this will <em>not</em>
create an object and thus is expected to put less load on the garbage
collector. It will accept some more spellings of NaN and infinity, thus
removing the need for checking for these independently.

@param str String
@param start Begin
@param end End
@return Double value