code: @Override
    public double nextDouble()
    {
      int p = peeked;
      if (p == PEEKED_NONE) {
        p = doPeek();
      }
  
      if (p == PEEKED_LONG) {
        peeked = PEEKED_NONE;
        return (double) peekedLong;
      }
  
      if (p == PEEKED_NUMBER) {
        peekedString = new String(buffer, pos, peekedNumberLength);
        pos += peekedNumberLength;
      } else if (p == PEEKED_SINGLE_QUOTED || p == PEEKED_DOUBLE_QUOTED) {
        peekedString = nextQuotedValue(p == PEEKED_SINGLE_QUOTED ? '\'' : '"');
      } else if (p == PEEKED_UNQUOTED) {
        peekedString = nextUnquotedValue();
      } else if (p != PEEKED_BUFFERED) {
        throw new IllegalStateException("Expected a double but was " + peek()
            + " at line " + getLineNumber() + " column " + getColumnNumber());
      }
  
      peeked = PEEKED_BUFFERED;
      double result = Double.parseDouble( peekedString ); // don't catch this NumberFormatException.
      if (!lenient && (Double.isNaN( result ) || Double.isInfinite( result ))) {
        throw syntaxError( "JSON forbids NaN and infinities: " + result);
      }
      peekedString = null;
      peeked = PEEKED_NONE;
      return result;
    }
docs: {@inheritDoc}