code: private void parseDouble(int start, int limit, boolean allowInfinity) {
          assert start<limit;
          // fake loop for easy exit and single throw statement
          for(;;) {
              // fast path for small integers and infinity
              int value=0;
              int isNegative=0;  // not boolean so that we can easily add it to value
              int index=start;
              char c=msg.charAt(index++);
              if(c=='-') {
                  isNegative=1;
                  if(index==limit) {
                      break;  // no number
                  }
                  c=msg.charAt(index++);
              } else if(c=='+') {
                  if(index==limit) {
                      break;  // no number
                  }
                  c=msg.charAt(index++);
              }
              if(c==0x221e) {  // infinity
                  if(allowInfinity && index==limit) {
                      addArgDoublePart(
                          isNegative!=0 ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY,
                          start, limit-start);
                      return;
                  } else {
                      break;
                  }
              }
              // try to parse the number as a small integer but fall back to a double
              while('0'<=c && c<='9') {
                  value=value*10+(c-'0');
                  if(value>(Part.MAX_VALUE+isNegative)) {
                      break;  // not a small-enough integer
                  }
                  if(index==limit) {
                      addPart(Part.Type.ARG_INT, start, limit-start, isNegative!=0 ? -value : value);
                      return;
                  }
                  c=msg.charAt(index++);
              }
              // Let Double.parseDouble() throw a NumberFormatException.
              double numericValue=Double.parseDouble(msg.substring(start, limit));
              addArgDoublePart(numericValue, start, limit-start);
              return;
          }
          throw new NumberFormatException(
              "Bad syntax for numeric value: "+msg.substring(start, limit));
      }
docs: Parses a number from the specified message substring.
  @param start start index into the message string
  @param limit limit index into the message string, must be start<limit
  @param allowInfinity true if U+221E is allowed (for ChoiceFormat)