changeset 315:6e11eace1091

fix Ab_testing.format() git-svn-id: https://luan-java.googlecode.com/svn/trunk@316 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 26 Dec 2014 11:13:28 +0000
parents 7c4f52262213
children d6cce1cc8948
files core/src/luan/impl/ModExpr.java lucene/src/luan/modules/lucene/Ab_testing.luan
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
diff -r 7c4f52262213 -r 6e11eace1091 core/src/luan/impl/ModExpr.java
--- a/core/src/luan/impl/ModExpr.java	Thu Dec 25 07:23:32 2014 +0000
+++ b/core/src/luan/impl/ModExpr.java	Fri Dec 26 11:13:28 2014 +0000
@@ -16,8 +16,11 @@
 		Object o2 = op2.eval(luan);
 		Number n1 = Luan.toNumber(o1);
 		Number n2 = Luan.toNumber(o2);
-		if( n1 != null && n2 != null )
-			return n1.doubleValue() % n2.doubleValue();
+		if( n1 != null && n2 != null ) {
+			double d1 = n1.doubleValue();
+			double d2 = n2.doubleValue();
+			return d1 - Math.floor(d1/d2)*d2;
+		}
 		return arithmetic(luan,"__mod",o1,o2);
 	}
 }
diff -r 7c4f52262213 -r 6e11eace1091 lucene/src/luan/modules/lucene/Ab_testing.luan
--- a/lucene/src/luan/modules/lucene/Ab_testing.luan	Thu Dec 25 07:23:32 2014 +0000
+++ b/lucene/src/luan/modules/lucene/Ab_testing.luan	Fri Dec 26 11:13:28 2014 +0000
@@ -195,7 +195,7 @@
 
 local function format(v)
 	v = v .. ''
-	return v.gsub('(\d+.\d{1})\d+','$1')
+	return v.gsub([[(\d+\.\d{1})\d+]],'$1')
 end
 
 function html(test_names,tests,results) %>