Rounds a number down to the nearest integer
337793
def _int(ctx, number):
    
    return conversions.to_integer(conversions.to_decimal(number, ctx).to_integral_value(ROUND_FLOOR), ctx)
354658
def frange(start, stop, step, precision):
    """"""
    value = start
    while round(value, precision) < stop:
        yield round(value, precision)
        value += step
1064584
def decimal_round(number, num_digits, rounding=ROUND_HALF_UP):
    
    exp = Decimal(10) ** -num_digits

    if num_digits >= 0:
        return number.quantize(exp, rounding)
    else:
        return exp * (number / exp).to_integral_value(rounding)
1237085
function closestNumber(arr, num) {
  return arr.reduce((prev, curr) => (Math.abs(curr - num) < Math.abs(prev - num)) ? curr : prev);
}
161057
function round(out, a) {
  out[0] = Math.round(a[0]);
  out[1] = Math.round(a[1]);
  out[2] = Math.round(a[2]);
  return out;
}
962295
def round_to_scale(number, precision):
    """"""
    if precision < 1:
        return round_to_float(number, precision)
    return round_to_int(number, precision)
894297
def round(digits = nil)
      rounded_value = digits ? value.round(digits) : value.round
      self.class.new(rounded_value, unit)
    end
172597
def _round_multiple(x:int, mult:int=None)->int:
    ""
    return (int(x/mult+0.5)*mult) if mult is not None else x
621330
function(number, precision) {

    const multiplier = !!precision ? Math.pow(10, precision) : 1;

    return Math.round(number * multiplier) / multiplier;
  }
991416
function roundNumber(parsedNumber, fractionSize, minFrac, maxFrac) {
    var digits = parsedNumber.d;
    var fractionLen = digits.length - parsedNumber.i;

    // determine fractionSize if it is not specified; `+fractionSize` converts it to a number
    fractionSize = (isUndefined(fractionSize)) ? Math.min(Math.max(minFrac, fractionLen), maxFrac) : +fractionSize;

    // The index of the digit to where rounding is to occur
    var roundAt = fractionSize + parsedNumber.i;
    var digit = digits[roundAt];

    if (roundAt > 0) {
      // Drop fractional digits beyond `roundAt`
      digits.splice(Math.max(parsedNumber.i, roundAt));

      // Set non-fractional digits beyond `roundAt` to 0
      for (var j = roundAt; j < digits.length; j++) {
        digits[j] = 0;
      }
    } else {
      // We rounded to zero so reset the parsedNumber
      fractionLen = Math.max(0, fractionLen);
      parsedNumber.i = 1;
      digits.length = Math.max(1, roundAt = fractionSize + 1);
      digits[0] = 0;
      for (var i = 1; i < roundAt; i++) digits[i] = 0;
    }

    if (digit >= 5) {
      if (roundAt - 1 < 0) {
        for (var k = 0; k > roundAt; k--) {
          digits.unshift(0);
          parsedNumber.i++;
        }
        digits.unshift(1);
        parsedNumber.i++;
      } else {
        digits[roundAt - 1]++;
      }
    }

    // Pad out with zeros to get the required fraction length
    for (; fractionLen < Math.max(0, fractionSize); fractionLen++) digits.push(0);


    // Do any carrying, e.g. a digit was rounded up to 10
    var carry = digits.reduceRight(function(carry, d, i, digits) {
      d = d + carry;
      digits[i] = d % 10;
      return Math.floor(d / 10);
    }, 0);
    if (carry) {
      digits.unshift(carry);
      parsedNumber.i++;
    }
}
565475
function roundToWithThousands(config, num, place) {
	var newval = 1 * unFormat(config, num);
	if (typeof(newval) == "number" && place != "none") {
		if (place <= 0) {
			var roundVal = -place;
			newval = +(Math.round(newval + "e+" + roundVal) + "e-" + roundVal);
		} else {
			var roundVal = place;
			var divval = "1e+" + roundVal;
			newval = +(Math.round(newval / divval)) * divval;
		}
	}
	newval = fmtChartJS(config, newval, "none");
	return (newval);
}
799844
function roundToNumber(num, place) {
    var newval=1*num;

    if(typeof(newval)=="number"){
      if(place<=0){
        var roundVal=-place;
        newval= +(Math.round(newval + "e+" + roundVal) + "e-" + roundVal);
      }
      else {
        var roundVal=place;
        var divval= "1e+"+roundVal;
        newval= +(Math.round(newval/divval))*divval;
      }
    }
    return(newval);
}
569208
def teachers_round(x):
    '''
    
    '''
    if ((x > 0) and (x % 1 >= 0.5)) or ((x < 0) and (x % 1 > 0.5)):
        return int(np.ceil(x))
    else:
        return int(np.floor(x))
214176
function roundInt(str, precision = +Infinity) {
  if (!isNumStr(str, 10)) throw new Error('in roundInt, string must be an integer in base 10.');
  if (precision <= 0) throw new Error('in roundInt, precision must be greater than 0.');
  const minus = String.fromCharCode(consts.minus);
  
  str = rectify(str);

  // If the number is negative, ignore the negative sign for now.
  let start = (str[0] == minus) ? 1 : 0;

  // If the length of the number is less than or equal to precision, return the number.
  if (str.length - start <= precision) return str;

  // Get the significant part, the digit following, and the remaining digits.
  let sigPart = str.slice(start, precision + start);
  let nextDigit = charToVal(str[precision + start]);
  let remainder = str.slice(precision + start + 1);

  // Decide whether to increment the significant part; round half to even.
  let increment = false;
  if (nextDigit > 5) increment = true;
  else if (nextDigit == 5) {
    if (!isEntirely(remainder, consts.alphabet[0])) increment = true;  // inc if remainder is nonzero
    else {
      let lSigDigit = charToVal(sigPart[precision - 1]); // otherwise inc if it will give you an even number.
      if (lSigDigit % 2) increment = true;
    }
  }
  if (increment) sigPart = incInt(sigPart);

  // The rounded value is the significant part padded with zeros.
  let roundedLength = sigPart.length + 1 + remainder.length;
  let rounded = sigPart.padEnd(roundedLength, consts.alphabet[0]);

  // If the value was negative, replace the negative sign.
  rounded = (str[0] == minus) ? minus + rounded : rounded;

  return rounded;
}
408343
def round(ndigits = 0)
      if_timezone_offset(super) {|o,t| self.class.at(t.to_i, t.subsec * 1_000_000).set_timezone_offset(o) }
    end
804193
function round(number, fraction) {
    return Math.round(number * Math.pow(10, fraction)) / Math.pow(10, fraction)
}
558474
function closest(obj, number){		
		if((current = obj.length) < 2)
			return l - 1;
			
		for(var current, previous = Math.abs(obj[--current] - number); current--;)
			if(previous < (previous = Math.abs(obj[current] - number)))
				break;
				
		return obj[current + 1];
	
		var closest = -1,
			prev = Math.abs(obj[0] - number);
		
		for (var i = 1; i < obj.length; i++){
			var diff = Math.abs(obj[i] - number);
			
			if (diff <= prev){
				prev = diff;
				closest = obj[i];
			}
		}
		
		return closest;
	}