round.js 485 B

12345678910111213141516171819202122232425
  1. var createRound = require('../internal/createRound');
  2. /**
  3. * Calculates `n` rounded to `precision`.
  4. *
  5. * @static
  6. * @memberOf _
  7. * @category Math
  8. * @param {number} n The number to round.
  9. * @param {number} [precision=0] The precision to round to.
  10. * @returns {number} Returns the rounded number.
  11. * @example
  12. *
  13. * _.round(4.006);
  14. * // => 4
  15. *
  16. * _.round(4.006, 2);
  17. * // => 4.01
  18. *
  19. * _.round(4060, -2);
  20. * // => 4100
  21. */
  22. var round = createRound('round');
  23. module.exports = round;