[Pkg-javascript-commits] [dojo] 44/88: Fixes #16411. IE only needed a workaround for rounding [0.5, 0.95) instead [0.5, 1.0). Added automated tests. !strict

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.8.5
in repository dojo.

commit f8bed4f100c06147ffe482a5cf672d70640f7a15
Author: Douglas Hays <doughays at dojotoolkit.org>
Date:   Fri Nov 30 18:21:42 2012 +0000

    Fixes #16411.  IE only needed a workaround for rounding [0.5,0.95) instead [0.5,1.0).  Added automated tests. !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.8/dojo@30094 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 number.js       | 7 ++++++-
 tests/number.js | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/number.js b/number.js
index 98d6976..a6c73d5 100644
--- a/number.js
+++ b/number.js
@@ -137,8 +137,13 @@ if((0.9).toFixed() == 0){
 	var round = number.round;
 	number.round = function(v, p, m){
 		var d = Math.pow(10, -p || 0), a = Math.abs(v);
-		if(!v || a >= d || a * Math.pow(10, p + 1) < 5){
+		if(!v || a >= d){
 			d = 0;
+		}else{
+			a /= d;
+			if(a < 0.5 || a >= 0.95){
+				d = 0;
+			}
 		}
 		return round(v, p, m) + (v > 0 ? d : -d);
 	};
diff --git a/tests/number.js b/tests/number.js
index 2ecc36a..76cda0b 100644
--- a/tests/number.js
+++ b/tests/number.js
@@ -171,6 +171,11 @@ doh.register("tests.number",
 				t.is(1, dojo.number.round(0.5));
 				t.is(-1, dojo.number.round(-0.5));
 				t.is(0.1, dojo.number.round(0.05, 1));
+				t.is(0.1, dojo.number.round(0.09, 1));
+				t.is(0.0, dojo.number.round(0.04999999, 1));
+				t.is(0.1, dojo.number.round(0.09499999, 1));
+				t.is(0.1, dojo.number.round(0.095, 1));
+				t.is(0.1, dojo.number.round(0.09999999, 1));
 				t.is(-0.1, dojo.number.round(-0.05, 1));
 				t.is(1.1, dojo.number.round(1.05, 1));
 				t.is(-1.1, dojo.number.round(-1.05, 1));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list