Mercurial Hosting > luan
view core/src/luan/impl/ModExpr.java @ 369:85bf9f0379aa
template statements no longer depend on 'Io' being defined
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 17 Apr 2015 06:25:38 -0600 |
parents | 6e11eace1091 |
children | bbad2d06f728 |
line wrap: on
line source
package luan.impl; import luan.Luan; import luan.LuanException; import luan.LuanSource; final class ModExpr extends BinaryOpExpr { ModExpr(LuanSource.Element se,Expr op1,Expr op2) { super(se,op1,op2); } @Override public Object eval(LuanStateImpl luan) throws LuanException { Object o1 = op1.eval(luan); Object o2 = op2.eval(luan); Number n1 = Luan.toNumber(o1); Number n2 = Luan.toNumber(o2); 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); } }