Nodejs Utililty Methods Float Round

List of utility methods to do Float Round

Description

The list of methods to do Float Round are organized into topic(s).

Method

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;
...
round(dp)
Number.prototype.round = function(dp) {
    multiplier = Math.pow(10,dp);
    return Math.round(this*multiplier) / multiplier;
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) {
...
round(precision)
Number.prototype.round = function(precision) {
  var factor = Math.pow(10, precision || 0);
  return Math.round(this * factor) / factor;
};
round(precision)
Number.prototype.round = function(precision){
  if (Object.isUndefined(precision)){
    return Math.round(this);
  precision = Math.pow(10, precision);
  return Math.round(this * precision) / precision;
};
round(precision)
Number.prototype.round = function (precision) {
    precision = Math.pow(10, precision || 0);
    return Math.round(this * precision) / precision;
};
round5()
Number.prototype.round5 = function() {
  return ((this)- (this % 5));
roundDecimal()
Number.prototype.roundDecimal = function() {
  return Math.roundDecimal(this);
};
roundMoney(decimals = 2)
Number.prototype.roundMoney = Number.prototype.toObject || function roundMoney(decimals = 2) {
  return Number((Math.round(this + "e" + decimals) + "e-" + decimals));
};
roundNumber.prototype.round || (precision)
Number.prototype.round = Number.prototype.round || function (precision) {
  return Math.round(this * Math.pow(10, (precision || 2))) / Math.pow(10, (precision || 2))