Nodejs Float Round round()

Here you can find the source of round()

Method Source Code

Number.prototype.round = function() {
  return Math.round(this);
};

Related

  1. roundTo(num, to)
    Math.roundTo = function roundTo (num, to) {
        if (num < to / 2) {
            return 0;
        var amount = to * Math.round(num / to);
        if (amount === 0) {
            amount = to;
        return amount;
    ...
    
  2. decRound(num, decimals)
    function MyMath () {}
    MyMath.decRound = function(num, decimals){
        return Math.round(num*Math.pow(10,decimals))/Math.pow(10,decimals);
    
  3. $round(fractionalDigits)
    Number.prototype.$round = function(fractionalDigits) {
        return parseFloat(this.toFixed(fractionalDigits));
    };
    
  4. ToRound(digits)
    Number.prototype.ToRound = function (digits) {
        if (digits < 0 || digits > 10)
            return this;
        var pow10 = Math.pow(10, digits);
        return Math.round(this * pow10) / pow10;
    };
    
  5. round()
    Number.prototype.round = function() {
      return Math.round(this);
    };
    
  6. round(d)
    Number.prototype.round = function(d) {
      const string_number = String(this)
      const split_string = string_number.split('.')
      if (split_string.length === 1) return this
      const integer_chunk = split_string[0]
      if (!d) return integer_chunk
      const decimal_chunk = split_string[1]
      const determinig_digit = parseInt(decimal_chunk[d])
      if (determinig_digit < 5) {
    ...
    
  7. round(decimals)return round(this,decimals);}
    exports.round = function(number,decimals){return round(number,decimals);}
    Number.prototype.round = function(decimals){return round(this,decimals);}
    var round = function(number,decimals){
      if(!isNaN(number)){
        var d = 1;
        if(!isNaN(decimals)){
          d = Math.pow(10,decimals)
        return Math.round(number * d)/d;
    ...
    
  8. round(dp)
    Number.prototype.round = function(dp) {
        multiplier = Math.pow(10,dp);
        return Math.round(this*multiplier) / multiplier;
    
  9. round(places)
    Number.prototype.round = function(places) {
        return +(Math.round(this + "e+" + places)  + "e-" + places);
    function fractionToFloat(str)
    var complexParts = str.split(' ');
    var result = 0;
    var f;
    if (complexParts.length == 1) {
    ...