Roo/util/Math.js
authorAlan Knowles <alan@akbkhome.com>
Wed, 12 Jan 2011 05:14:28 +0000 (13:14 +0800)
committerAlan Knowles <alan@akbkhome.com>
Wed, 12 Jan 2011 05:14:28 +0000 (13:14 +0800)
Roo/util/Math.js

index 8cb5710..109aecf 100644 (file)
@@ -7,23 +7,7 @@ Roo = typeof(Roo) != 'undefined' ? Roo :  { util : { }};
     
 
 Roo.util.Math = function(num, precision, roundType){
-       var i;
-       if(num instanceof Roo.util.Math){
-        var o = this;
-               for(i in {precision: 0, roundType: 0, _s: 0, _f: 0}) o[i] = num[i];
-               this._d = num._d.slice();
-               return;
-       }
-    
-       this.precision = isNaN(precision = Math.abs(precision)) ? Roo.util.Math.defaultPrecision : precision;
-       this.roundType = isNaN(r = Math.abs(roundType)) ? Roo.util.Math.defaultRoundType : roundType;
-    
-       this._s = (num += "").charAt(0) == "-";
-       this._f = (
-            (num = num.replace(/[^\d.]/g, "").split(".", 2))[0] = num[0].replace(/^0+/, "") || "0"
-        ).length;
-       for(i = (num = this._d = (num.join("") || "0").split("")).length; i; num[--i] = +num[i]);
-       this.round();
+       this._constructor(num,precision, roundType);
 };
 
 Roo.util.Math.ROUND_HALF_EVEN = (Roo.util.Math.ROUND_HALF_DOWN = (Roo.util.Math.ROUND_HALF_UP =