/* static functions 
FASTAReader.pos2index
convert DNA base position to character index
@param number  pos     : DNA base position
@param number  prelen  : header data length
@param number  linelen : one line length
@return number : character index
4822
function pos2index(pos, prelen, linelen) {
  return Number(prelen) + Number(pos) -1 + Math.floor( (pos -1)/linelen );
}
1051771
public static void indexToPointIndex( List<Point2D_I32> sequence , GrowQueue_I32 indexes ,
										  FastQueue<PointIndex_I32> output ) {
		output.reset();

		for( int i = 0; i < indexes.size; i++ ) {
			int index = indexes.data[i];
			Point2D_I32 p = sequence.get(index);

			PointIndex_I32 o = output.grow();
			o.x = p.x;
			o.y = p.y;
			o.index = index;
		}
	}
599409
private Number consumeTokenNumber(char c) throws JsonParserException {
    int start = index - 1;
    int end = index;

    boolean isDouble = false;
    while (isDigitCharacter(peekChar())) {
      char next = (char)advanceChar();
      isDouble = next == '.' || next == 'e' || next == 'E' || isDouble;
      end++;
    }

    String number = string.substring(start, end);

    try {
      if (isDouble) {
        // Special zero handling to match JSON spec. Leading zero is only allowed if next character is . or e
        if (number.charAt(0) == '0') {
          if (number.charAt(1) == '.') {
            if (number.length() == 2)
              throw createParseException(null, "Malformed number: " + number, true);
          } else if (number.charAt(1) != 'e' && number.charAt(1) != 'E')
            throw createParseException(null, "Malformed number: " + number, true);
        }
        if (number.charAt(0) == '-') {
          if (number.charAt(1) == '0') {
            if (number.charAt(2) == '.') {
              if (number.length() == 3)
                throw createParseException(null, "Malformed number: " + number, true);
            } else if (number.charAt(2) != 'e' && number.charAt(2) != 'E')
              throw createParseException(null, "Malformed number: " + number, true);
          } else if (number.charAt(1) == '.') {
            throw createParseException(null, "Malformed number: " + number, true);
          }
        }

        return Double.parseDouble(number);
      }

      // Special zero handling to match JSON spec. No leading zeros allowed for integers.
      if (number.charAt(0) == '0') {
        if (number.length() == 1)
          return 0;
        throw createParseException(null, "Malformed number: " + number, true);
      }
      if (number.length() > 1 && number.charAt(0) == '-' && number.charAt(1) == '0') {
        if (number.length() == 2)
          return -0.0;
        throw createParseException(null, "Malformed number: " + number, true);
      }

      // HACK: Attempt to parse using the approximate best type for this
      int length = number.charAt(0) == '-' ? number.length() - 1 : number.length();
      if (length < 10) // 2 147 483 647
        return Integer.parseInt(number);
      if (length < 19) // 9 223 372 036 854 775 807
        return Long.parseLong(number);
      return new BigInteger(number);
    } catch (NumberFormatException e) {
      throw createParseException(e, "Malformed number: " + number, true);
    }
  }
1341955
function BigNumber(initialNumber) {
        var index;

        if (!(this instanceof BigNumber)) {
            return new BigNumber(initialNumber);
        }

        this.number = [];
        this.sign = 1;
        this.rest = 0;

        // The initial number can be an array, string, number of another big number
        // e.g. array     : [3,2,1], ['+',3,2,1], ['-',3,2,1]
        //      number    : 312
        //      string    : '321', '+321', -321'
        //      BigNumber : BigNumber(321)
        // Every character except the first must be a digit

        if (!isValidType(initialNumber)) {
            this.number = errors['invalid'];
            return;
        }

        if (isArray(initialNumber)) {
            if (initialNumber.length && initialNumber[0] === '-' || initialNumber[0] === '+') {
                this.sign = initialNumber[0] === '+' ? 1 : -1;
                initialNumber.shift(0);
            }
            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(initialNumber[index]))
                    return;
            }
        } else {
            initialNumber = initialNumber.toString();
            if (initialNumber.charAt(0) === '-' || initialNumber.charAt(0) === '+') {
                this.sign = initialNumber.charAt(0) === '+' ? 1 : -1;
                initialNumber = initialNumber.substring(1);
            }

            for (index = initialNumber.length - 1; index >= 0; index--) {
                if (!this.addDigit(parseInt(initialNumber.charAt(index), 10))) {
                    return;
                }
            }
        }
    }
132260
def process_number(line, base, str)
      value = str.to_i base
      case value
      when Fixnum
        AST::FixnumLiteral.new line, value
      when Bignum
        AST::NumberLiteral.new line, value
      end
    end
67025
private int chn2Num(int chr){
		int temp;
		temp=this.strDigit.indexOf(chr);
		if(temp<0)
			return -1;
		if(temp<10)
			return temp/2+1;
		else if(temp<14)
			return temp-4;
		else return 0;
	}
943623
public HashMap<Integer, Integer> getAllNumberOfPositions(String field,
      int docBase) throws IOException {
    HashMap<Integer, Integer> numbers = new HashMap<Integer, Integer>();
    if (fieldReferences.containsKey(field)) {
      FieldReferences fr = fieldReferences.get(field);
      IndexInput inIndexDoc = indexInputList.get("doc");
      inIndexDoc.seek(fr.refIndexDoc);
      IndexDoc doc;
      for (int i = 0; i < fr.numberOfDocs; i++) {
        doc = new IndexDoc(null);
        numbers.put((doc.docId + docBase),
            (1 + doc.maxPosition - doc.minPosition));
      }
    }
    return numbers;
  }
458026
function posToLine(pos, src) {
    if (pos >= src.length) {
        pos = src.length - 1;
    }

    if (pos <= -1) {
        return -1;
    }

    let line = 1;
    for (let i = 0; i < pos; i++) {
        if (src[i] === "\n") {
            ++line;
        }
    }

    return line;
}
551956
public Token scanNumber() {
        int length = 0;
        if ('-' == charAt(offset + length)) {
            length++;
        }
        length += getDigitalLength(offset + length);
        boolean isFloat = false;
        if ('.' == charAt(offset + length)) {
            isFloat = true;
            length++;
            length += getDigitalLength(offset + length);
        }
        if (isScientificNotation(offset + length)) {
            isFloat = true;
            length++;
            if ('+' == charAt(offset + length) || '-' == charAt(offset + length)) {
                length++;
            }
            length += getDigitalLength(offset + length);
        }
        if (isBinaryNumber(offset + length)) {
            isFloat = true;
            length++;
        }
        return new Token(isFloat ? Literals.FLOAT : Literals.INT, input.substring(offset, offset + length), offset + length);
    }
604899
function precBase(base, value, precision) {
	const val = value.toString(base);
	const floatingPoint = val.indexOf('.');
	if (precision === 0 && floatingPoint > -1) {
		return val.substring(0, floatingPoint);//Node version > 0.10.*
	}
	if (floatingPoint === -1) {
		return val;
	}
	if (val.length - floatingPoint > precision) {
		return val.substring(0, floatingPoint + precision + 1);
	}
}
1091678
function line_number(index, source) {
  // To speed things up, remember the index until which we counted,
  // then next time just begin counting from there.  This way we
  // only count each line once.
  var i = start_index;
  var count = 0;
  while (i < index) {
    if (source[i] === "\n") {
      count++;
    }
    i++;
  }

  start_linenr = count + start_linenr;
  start_index = index;

  return start_linenr;
}
327209
public static StandardPlural selectPlural(
            Number number, NumberFormat fmt, PluralRules rules,
            StringBuffer formattedNumber, FieldPosition pos) {
        UFieldPosition fpos = new UFieldPosition(pos.getFieldAttribute(), pos.getField());
        fmt.format(number, formattedNumber, fpos);
        // TODO: Long, BigDecimal & BigInteger may not fit into doubleValue().
        FixedDecimal fd = new FixedDecimal(
                number.doubleValue(),
                fpos.getCountVisibleFractionDigits(), fpos.getFractionDigits());
        String pluralKeyword = rules.select(fd);
        pos.setBeginIndex(fpos.getBeginIndex());
        pos.setEndIndex(fpos.getEndIndex());
        return StandardPlural.orOtherFromString(pluralKeyword);
    }
1264016
function advanceTo(newPos) {
		let n = newPos - pos
		assert(n >= 0)
		while (n--) {
			if (source[pos] === '\n') {
				column = 1
				line++
			} else {
				column++
			}
			pos += 1
		}
	}
1283992
function getNumber() {
  const type = NodeType.NumberType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const l = tokens[pos].number_l;
  let content = '';

  for (let j = 0; j < l; j++) {
    content += tokens[pos + j].value;
  }

  pos += l;

  return newNode(type, content, line, column);
}
1153377
public static String getLargeNumber(final long pBigNumber) {

    StringBuilder buffer       = new StringBuilder(new Long(pBigNumber).toString());
    char[]       number       = new Long(pBigNumber).toString().toCharArray();
    int          reverseIndex = 0;

    for (int i = number.length; i >= 0; i--) {
      reverseIndex++;
      if ((reverseIndex % 3 == 0) && (i > 1)) {
        buffer = buffer.insert(i - 1, '.');
      }
    }
    return buffer.toString();
  }
566557
Number readNumber() throws IOException {
		StringBuilder intPart = null; // ###.xxxExxx
		StringBuilder fraPart = null; // xxx.###Exxx
		StringBuilder expPart = null; // xxx.xxxE###
		boolean hasFraPart = false;
		boolean hasExpPart = false;
		char ch = reader.peek();
		boolean minusSign = ch == '-';
		boolean expMinusSign = false;
		if (minusSign) {
			reader.next();
		}
		int status = READ_NUMBER_INT_PART;
		for (;;) {
			if (reader.hasMore()) {
				ch = reader.peek();
			} else {
				status = READ_NUMBER_END;
			}
			switch (status) {
			case READ_NUMBER_INT_PART:
				if (ch >= '0' && ch <= '9') {
					if (intPart == null) {
						intPart = new StringBuilder(10);
					}
					intPart.append(reader.next());
				} else if (ch == '.') {
					if (intPart == null) {
						throw new JsonParseException("Unexpected char: " + ch,
								reader.readed);
					}
					reader.next();
					hasFraPart = true;
					status = READ_NUMBER_FRA_PART;
				} else if (ch == 'e' || ch == 'E') {
					reader.next();
					hasExpPart = true;
					// try to determin exp part's sign:
					char signChar = reader.peek();
					if (signChar == '-' || signChar == '+') {
						expMinusSign = signChar == '-';
						reader.next();
					}
					status = READ_NUMBER_EXP_PART;
				} else {
					if (intPart == null) {
						throw new JsonParseException("Unexpected char: "
								+ reader.next(), reader.readed);
					}
					// end of number:
					status = READ_NUMBER_END;
				}
				continue;
			case READ_NUMBER_FRA_PART:
				if (ch >= '0' && ch <= '9') {
					if (fraPart == null) {
						fraPart = new StringBuilder(10);
					}
					fraPart.append(reader.next());
				} else if (ch == 'e' || ch == 'E') {
					reader.next();
					hasExpPart = true;
					// try to determin exp part's sign:
					char signChar = reader.peek();
					if (signChar == '-' || signChar == '+') {
						expMinusSign = signChar == '-';
						reader.next();
					}
					status = READ_NUMBER_EXP_PART;
				} else {
					if (fraPart == null) {
						throw new JsonParseException("Unexpected char: "
								+ reader.next(), reader.readed);
					}
					// end of number:
					status = READ_NUMBER_END;
				}
				continue;
			case READ_NUMBER_EXP_PART:
				if (ch >= '0' && ch <= '9') {
					if (expPart == null) {
						expPart = new StringBuilder(10);
					}
					expPart.append(reader.next());
				} else {
					if (expPart == null) {
						throw new JsonParseException("Unexpected char: "
								+ reader.next(), reader.readed);
					}
					// end of number:
					status = READ_NUMBER_END;
				}
				continue;
			case READ_NUMBER_END:
				// build parsed number:
				int readed = reader.readed;
				if (intPart==null) {
				    throw new JsonParseException("Missing integer part of number.", readed);
				}
				long lInt = minusSign ? -string2Long(intPart, readed)
						: string2Long(intPart, readed);
				if (!hasFraPart && !hasExpPart) {
					return new Long(lInt);
				}
				if (hasFraPart && fraPart == null) {
				    throw new JsonParseException("Missing fraction part of number.", readed);
				}
				double dFraPart = hasFraPart ? (minusSign ? -string2Fraction(fraPart, readed)
						: string2Fraction(fraPart, readed))
						: 0.0;
				double number = hasExpPart ? (lInt + dFraPart)
						* Math.pow(10, expMinusSign ? -string2Long(expPart, readed) : string2Long(expPart, readed))
						: (lInt + dFraPart);
				if (number > MAX_SAFE_DOUBLE) {
					throw new NumberFormatException(
							"Exceeded maximum value: 1.7976931348623157e+308");
				}
				return new Double(number);
			}
			continue;
		}
	}
1254262
function position(_, line) {
        if (!Array.isArray(_)) {
            return errors.push({
                message: 'position should be an array, is a ' + (typeof _) +
                    ' instead',
                line: _.__line__ || line
            });
        }
        if (_.length < 2) {
            return errors.push({
                message: 'position must have 2 or more elements',
                line: _.__line__ || line
            });
        }
        if (_.length > 3) {
            return errors.push({
                message: 'position should not have more than 3 elements',
                level: 'message',
                line: _.__line__ || line
            });
        }
        if (!everyIs(_, 'number')) {
            return errors.push({
                message: 'each element in a position must be a number',
                line: _.__line__ || line
            });
        }

        if (options && options.precisionWarning) {
            if (precisionWarningCount === maxPrecisionWarnings) {
                precisionWarningCount += 1;
                return errors.push({
                    message: 'truncated warnings: we\'ve encountered coordinate precision warning ' + maxPrecisionWarnings + ' times, no more warnings will be reported',
                    level: 'message',
                    line: _.__line__ || line
                });
            } else if (precisionWarningCount < maxPrecisionWarnings) {
                _.forEach(function(num) {
                    var precision = 0;
                    var decimalStr = String(num).split('.')[1];
                    if (decimalStr !== undefined)
                        precision = decimalStr.length;
                    if (precision > maxPrecision) {
                        precisionWarningCount += 1;
                        return errors.push({
                            message: 'precision of coordinates should be reduced',
                            level: 'message',
                            line: _.__line__ || line
                        });
                    }
                });
            }
        }
    }