Mercurial Hosting > luan
comparison core/src/luan/impl/DivExpr.java @ 446:bbad2d06f728
remove automatic conversion from string to number
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 May 2015 16:21:17 -0600 |
parents | 3dcb0f9bee82 |
children | b48cfa14ba60 |
comparison
equal
deleted
inserted
replaced
445:cc7d246bda2a | 446:bbad2d06f728 |
---|---|
1 package luan.impl; | 1 package luan.impl; |
2 | 2 |
3 import luan.Luan; | |
4 import luan.LuanException; | 3 import luan.LuanException; |
5 import luan.LuanSource; | 4 import luan.LuanSource; |
6 | 5 |
7 | 6 |
8 final class DivExpr extends BinaryOpExpr { | 7 final class DivExpr extends BinaryOpExpr { |
12 } | 11 } |
13 | 12 |
14 @Override public Object eval(LuanStateImpl luan) throws LuanException { | 13 @Override public Object eval(LuanStateImpl luan) throws LuanException { |
15 Object o1 = op1.eval(luan); | 14 Object o1 = op1.eval(luan); |
16 Object o2 = op2.eval(luan); | 15 Object o2 = op2.eval(luan); |
17 Number n1 = Luan.toNumber(o1); | 16 if( o1 instanceof Number && o2 instanceof Number ) |
18 Number n2 = Luan.toNumber(o2); | 17 return ((Number)o1).doubleValue() / ((Number)o2).doubleValue(); |
19 if( n1 != null && n2 != null ) | |
20 return n1.doubleValue() / n2.doubleValue(); | |
21 return arithmetic(luan,"__div",o1,o2); | 18 return arithmetic(luan,"__div",o1,o2); |
22 } | 19 } |
23 } | 20 } |