Nodejs Float Round roundTo(num, dec)

Here you can find the source of roundTo(num, dec)

Method Source Code

Math.roundTo = function (num, dec) {
  return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
};

Related

  1. round(value)
    Util.round = function(value) {
      return new Number((new Number(value)).toFixed(2));
    };
    
  2. roundTo (num, to)
    Math.ceilTo = function roundTo (num, to) {
        if (num < to) {
            return to;
        var amount = to * Math.ceil(num / to);
        if (amount === 0) {
            amount = to;
        return amount;
    ...
    
  3. 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;
    ...
    
  4. decRound(num, decimals)
    function MyMath () {}
    MyMath.decRound = function(num, decimals){
        return Math.round(num*Math.pow(10,decimals))/Math.pow(10,decimals);