if(digitType==0 && digitsFound[0]==0) break;
  public double toDouble()  {    int end = m_length+m_start;    if(0 == end)      return Double.NaN;    int start = m_start;    FastStringBuffer fsb = fsb();          long longResult=0;    boolean isNegative=false;    boolean trailingSpace=false;    int[] digitsFound={0,0}; // intpart,fracpart    int digitType=0;    // Index to which kind of digit we're accumulating    double doubleResult;    int overflow=0;        // Scan past leading whitespace characters    while(start< end &&          XMLCharacterRecognizer.isWhiteSpace( fsb.charAt(start) )          )      ++start;        if (start < end && fsb.charAt(start) == '-')    {      isNegative=true;      start++;    }        // parse the string from left to right converting as an integer.    for (int i = start; i < end; i++)    {      char c = fsb.charAt(i);      if(XMLCharacterRecognizer.isWhiteSpace(c))      {				trailingSpace=true;        break;                  // Trailing whitespace is ignored      }      else if(trailingSpace)	return Double.NaN;	// Nonspace after space is poorly formed	      switch(c)      {      case '.':        if(digitType==0)          digitType=1;        else          return Double.NaN;    // Second period is error	break;	      case '0':			// NOT Unicode isDigit();  ASCII digits _only_	if(digitType==0 && digitsFound[0]==0)   // Ignore leading zeros	  break;	// Else fall through into normal digit handling.      case '1':      case '2':      case '3':      case '4':      case '5':      case '6':      case '7':      case '8':      case '9':	// We have a potential overflow issue that we need	// to guard against. See Bugzilla 5346.	//	// %REVIEW% MUST BE RECONSIDERED. I _think_ the truncation of	// the 64-bit long before it overflows is well within the acceptable	// error range of the double's 53-bit mantissa...	if(longResult>MAX_NO_OVERFLOW_RISK)	{	  if(digitType==0) ++overflow;	}	else	{	  longResult=longResult*10 + (c - '0');	  ++digitsFound[digitType]; // Remember scaling	}	break;      default:        return Double.NaN;      // Nonnumeric is error      }    }    if(0 ==digitsFound[0]&& 0==digitsFound[1])      return Double.NaN;    // Convert from scaled integer to floating point. This will come close.     // There's an alternative solution involving Double.longBitsToDouble    // followed by a combined renormalize/scale operation... but I honestly    // think the more straightforward solution comes out to just about    // the same thing.                    long scale=1;               // AFAIK, java doesn't have an easier 10^n operation        doubleResult=(double)longResult;    if(digitsFound[1]==0)		// Integer overflow scaling    {	    for(int i=overflow;i>0;--i)  		     scale*=10;	 	doubleResult*=scale;    }    else 						// Fractional-part scaling    {    	// Complication: In values <0, the fractional part may want to be divided    	// by a power of 10 too large to fit in a long! In that case, resort to     	// successive divisions.     	//    	// %REVIEW% This can't be an optimal solution. Need a better algorithm. 	    int i=digitsFound[1]; 	    while(i>0) 	    { 	    	int j=(i<18) ? i : 18; 	    	i-=j; 	    			    for(scale=1;j>0;--j) 		    	scale*=10; 	     		    doubleResult/=scale; 	    }    }                    if(isNegative)      doubleResult *= -1;    return doubleResult;  }