From 80ffd4156063a081a1c880dbdba78b84a4abbba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 12 Feb 2013 14:16:06 -0800 Subject: [PATCH] Add optional precision argument to Base.formatFloat(). --- src/core/Base.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/Base.js b/src/core/Base.js index 17994e7c..a1857be2 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -433,9 +433,11 @@ this.Base = Base.inject(/** @lends Base# */{ * up to the amount of fractional digits. * * @param {Number} num the number to be converted to a string + * @param {Number} [precision=5] the amount of fractional digits. */ - formatFloat: function(num) { - return (Math.round(num * 100000) / 100000).toString(); + formatFloat: function(num, precision) { + precision = precision ? Math.pow(10, precision) : 100000; + return (Math.round(num * precision) / precision); }, toFloat: function(str) {