Mercurial Hosting > luan
comparison core/src/luan/impl/ModExpr.java @ 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 | 3dcb0f9bee82 |
children | bbad2d06f728 |
comparison
equal
deleted
inserted
replaced
314:7c4f52262213 | 315:6e11eace1091 |
---|---|
14 @Override public Object eval(LuanStateImpl luan) throws LuanException { | 14 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
15 Object o1 = op1.eval(luan); | 15 Object o1 = op1.eval(luan); |
16 Object o2 = op2.eval(luan); | 16 Object o2 = op2.eval(luan); |
17 Number n1 = Luan.toNumber(o1); | 17 Number n1 = Luan.toNumber(o1); |
18 Number n2 = Luan.toNumber(o2); | 18 Number n2 = Luan.toNumber(o2); |
19 if( n1 != null && n2 != null ) | 19 if( n1 != null && n2 != null ) { |
20 return n1.doubleValue() % n2.doubleValue(); | 20 double d1 = n1.doubleValue(); |
21 double d2 = n2.doubleValue(); | |
22 return d1 - Math.floor(d1/d2)*d2; | |
23 } | |
21 return arithmetic(luan,"__mod",o1,o2); | 24 return arithmetic(luan,"__mod",o1,o2); |
22 } | 25 } |
23 } | 26 } |