Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / math / round.js

History | View | Annotate | Download (759 Bytes)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.math.round"]){
9
dojo._hasResource["dojox.math.round"]=true;
10
dojo.provide("dojox.math.round");
11
dojo.experimental("dojox.math.round");
12
dojox.math.round=function(_1,_2,_3){
13
var _4=Math.log(Math.abs(_1))/Math.log(10);
14
var _5=10/(_3||10);
15
var _6=Math.pow(10,-15+_4);
16
return (_5*(+_1+(_1>0?_6:-_6))).toFixed(_2)/_5;
17
};
18
if((0.9).toFixed()==0){
19
(function(){
20
var _7=dojox.math.round;
21
dojox.math.round=function(v,p,m){
22
var d=Math.pow(10,-p||0),a=Math.abs(v);
23
if(!v||a>=d||a*Math.pow(10,p+1)<5){
24
d=0;
25
}
26
return _7(v,p,m)+(v>0?d:-d);
27
};
28
})();
29
}
30
}