examples/ionic1/www/lib/ionic/js/ionic.bundle.js
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++;
    }
}
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++;
    }
}
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 ++ ; } }
Round the parsed number to the specified number of decimal places
This function changed the parsedNumber in-place
Round the parsed number to the specified number of decimal places This function changed the parsedNumber in - place