Round the representation to the given number of digits.
@param maximumDigits The maximum number of digits to be shown.
Upon return, count will be less than or equal to maximumDigits.
773250
private final void round(int maximumDigits) {
        // Eliminate digits beyond maximum digits to be displayed.
        // Round up if appropriate.
        if (maximumDigits >= 0 && maximumDigits < count) {
            if (shouldRoundUp(maximumDigits)) {
                // Rounding up involved incrementing digits from LSD to MSD.
                // In most cases this is simple, but in a worst case situation
                // (9999..99) we have to adjust the decimalAt value.
                for (;;) {
                    --maximumDigits;
                    if (maximumDigits < 0) {
                        // We have all 9's, so we increment to a single digit
                        // of one and adjust the exponent.
                        digits[0] = '1';
                        ++decimalAt;
                        maximumDigits = 0; // Adjust the count
                        break;
                    }

                    ++digits[maximumDigits];
                    if (digits[maximumDigits] <= '9') break;
                    // digits[maximumDigits] = '0'; // Unnecessary since we'll truncate this
                }
                ++maximumDigits; // Increment for use as count
            }
            count = maximumDigits;

            // Eliminate trailing zeros.
            while (count > 1 && digits[count-1] == '0') {
                --count;
            }
        }
    }
74761
def grouped_digits(digits)
      unless (digits.size % @base_scale) == 0
        raise "Invalid number of digits for group_digits (#{digits.size} is not a multiple of #{@base_scale})"
      end
      digits.each_slice(@base_scale).map{|group| scaled_digit(group)}
    end
239679
public void setPattern(NumberPattern pattern, int _maxSigDigits, int _minSigDigits) {
    Format format = pattern.format();
    minIntDigits = orDefault(options.minimumIntegerDigits(), format.minimumIntegerDigits());

    maxFracDigits = currencyDigits == -1 ? format.maximumFractionDigits() : currencyDigits;
    maxFracDigits = orDefault(options.maximumFractionDigits(), maxFracDigits);

    minFracDigits = currencyDigits == -1 ? format.minimumFractionDigits() : currencyDigits;
    minFracDigits = orDefault(options.minimumFractionDigits(), minFracDigits);

    boolean useSignificant = formatMode == SIGNIFICANT || formatMode == SIGNIFICANT_MAXFRAC;
    if (useSignificant) {
        maxSigDigits = orDefault(options.maximumSignificantDigits(), _maxSigDigits);
        minSigDigits = orDefault(options.minimumSignificantDigits(), _minSigDigits);
    } else {
        maxSigDigits = -1;
        minSigDigits = -1;
    }
  }
62654
public int getMaximumDigits() {
        String value = Optional.fromNullable(getParameter(SignalParameters.MAXIMUM_NUM_DIGITS.symbol())).or("1");
        return Integer.parseInt(value);
    }
735002
function(digits, n) {
		n = n.toString();
		while(n.length < digits)
		n = '0' + n;
		return n;
	}
968829
public static String padWithMax(final int numToPad, final int maxValue) {
    checkArgument(numToPad >= 0);
    checkArgument(numToPad <= maxValue);
    final int maxLength = Integer.toString(maxValue).length();
    final String baseString = Integer.toString(numToPad);
    final String padding = Strings.repeat("0", maxLength - baseString.length());
    return padding + numToPad;
  }
1284092
private void round() {
        this.v0 += this.v1;
        this.v2 += this.v3;
        this.v1 = rotateLeft(this.v1, 13);
        this.v3 = rotateLeft(this.v3, 16);

        this.v1 ^= this.v0;
        this.v3 ^= this.v2;
        this.v0 = rotateLeft(this.v0, 32);

        this.v2 += this.v1;
        this.v0 += this.v3;
        this.v1 = rotateLeft(this.v1, 17);
        this.v3 = rotateLeft(this.v3, 21);

        this.v1 ^= this.v2;
        this.v3 ^= this.v0;
        this.v2 = rotateLeft(this.v2, 32);
    }
254784
def round(self, ndigits=0):
        
        if ndigits is None:
            ndigits = 0
        return self.__class__(
            amount=self.amount.quantize(Decimal('1e' + str(-ndigits))),
            currency=self.currency)
816737
public static BigDecimal round(EvaluationContext ctx, Object number, Object numDigits) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        int _numDigits = Conversions.toInteger(numDigits, ctx);

        return ExpressionUtils.decimalRound(_number, _numDigits, RoundingMode.HALF_UP);
    }
1139420
public static /*@pure@*/ int maxIndex(int[] ints) {

    int maximum = 0;
    int maxIndex = 0;

    for (int i = 0; i < ints.length; i++) {
      if ((i == 0) || (ints[i] > maximum)) {
	maxIndex = i;
	maximum = ints[i];
      }
    }

    return maxIndex;
  }
373650
public void setDigits4Map(String[] digits4Map) {

        ArgUtils.notEmpty(digits4Map, "digits4Map");

        if(digits4Map.length != 4) {
            throw new IllegalArgumentException("digits4Map length should be 4.");
        }

        this.digits4Map = digits4Map;
    }
1209457
public void print() {
        /*
        System.out.println(m00 + " " + m01 + " " + m02 + " " + m03 + "\n" +
                           m10 + " " + m11 + " " + m12 + " " + m13 + "\n" +
                           m20 + " " + m21 + " " + m22 + " " + m23 + "\n" +
                           m30 + " " + m31 + " " + m32 + " " + m33 + "\n");
         */
        int big = (int) Math.abs(Math.max(Math.max(Math.max(Math.max(Math.abs(m00), Math.abs(m01)),
            Math.max(Math.abs(m02), Math.abs(m03))),
            Math.max(Math.max(Math.abs(m10), Math.abs(m11)),
                Math.max(Math.abs(m12), Math.abs(m13)))),
                Math.max(Math.max(Math.max(Math.abs(m20), Math.abs(m21)),
                    Math.max(Math.abs(m22), Math.abs(m23))),
                    Math.max(Math.max(Math.abs(m30), Math.abs(m31)),
                        Math.max(Math.abs(m32), Math.abs(m33))))));

        int digits = 1;
        if (Double.isNaN(big) || Double.isInfinite(big)) {  // avoid infinite loop
            digits = 5;
        } else {
            while ((big /= 10) != 0) digits++;  // cheap log()
        }

        System.out.println(nfs(m00, digits, 4) + " " +
                           nfs(m01, digits, 4) + " " +
                           nfs(m02, digits, 4) + " " +
                           nfs(m03, digits, 4));

        System.out.println(nfs(m10, digits, 4) + " " +
                           nfs(m11, digits, 4) + " " +
                           nfs(m12, digits, 4) + " " +
                           nfs(m13, digits, 4));

        System.out.println(nfs(m20, digits, 4) + " " +
                           nfs(m21, digits, 4) + " " +
                           nfs(m22, digits, 4) + " " +
                           nfs(m23, digits, 4));

        System.out.println(nfs(m30, digits, 4) + " " +
                           nfs(m31, digits, 4) + " " +
                           nfs(m32, digits, 4) + " " +
                           nfs(m33, digits, 4));

        System.out.println();
    }
406436
private void tokenStatsAdd(int min, int max) {
    tokenStatsNumber++;
    if (tokenStatsMinPos == null) {
      tokenStatsMinPos = min;
    } else {
      tokenStatsMinPos = Math.min(tokenStatsMinPos, min);
    }
    if (tokenStatsMaxPos == null) {
      tokenStatsMaxPos = max;
    } else {
      tokenStatsMaxPos = Math.max(tokenStatsMaxPos, max);
    }
  }
131578
public static int max(int[] values)
    {
        int max = Integer.MIN_VALUE;

        for (int i = 0; i < values.length; ++i)
        {
            if (max < values[i])
            {
                max = values[i];
            }
        }

        return max;
    }
409186
protected String zeroPaddingNumber(long value, int minDigits, int maxDigits)
    {
        numberFormat.setMinimumIntegerDigits(minDigits);
        numberFormat.setMaximumIntegerDigits(maxDigits);
        return numberFormat.format(value);
    }
257097
def _smart_round(figure, width=10, max_decimal=4):
    """"""
    n_digits = len(str(int(figure)))
    n_decimal = width - (n_digits + 1)
    if n_decimal <= 1:
        return str(int(figure))
    else:
        n_decimal = min(n_decimal, max_decimal)
        format_str = "%." + str(n_decimal) + "f"
        return format_str % figure
94153
private function validateDigits(& $digits)
    {
        ksort($digits);

        if (count($digits) < 2) {
            throw new \InvalidArgumentException('Number base must have at least 2 digits');
        } elseif (array_keys($digits) !== range(0, count($digits) - 1)) {
            throw new \InvalidArgumentException('Invalid digit values in the number base');
        } elseif ($this->detectDuplicates($digits)) {
            throw new \InvalidArgumentException('Number base cannot have duplicate digits');
        }
    }