diff src/luan/LuaState.java @ 46:a443637829c1

remove LuaNumber git-svn-id: https://luan-java.googlecode.com/svn/trunk@47 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 27 Dec 2012 01:48:36 +0000
parents 57054fa43189
children
line wrap: on
line diff
--- a/src/luan/LuaState.java	Thu Dec 27 00:44:58 2012 +0000
+++ b/src/luan/LuaState.java	Thu Dec 27 01:48:36 2012 +0000
@@ -46,8 +46,8 @@
 		return s;
 	}
 
-	public final LuaNumber checkNumber(LuaElement el,Object obj) throws LuaException {
-		LuaNumber n = Lua.toNumber(obj);
+	public final Number checkNumber(LuaElement el,Object obj) throws LuaException {
+		Number n = Lua.toNumber(obj);
 		if( n == null )
 			throw new LuaException( this, el, "attempt to perform arithmetic on a " + Lua.type(obj) + " value" );
 		return n;
@@ -65,6 +65,8 @@
 			return checkString( el, Lua.first( call(fn,el,"__tostring",obj) ) );
 		if( obj == null )
 			return "nil";
+		if( obj instanceof Number )
+			return Lua.toString((Number)obj);
 		if( obj instanceof LuaException ) {
 			LuaException le = (LuaException)obj;
 			return le.getMessage();
@@ -93,10 +95,10 @@
 	}
 
 	public final boolean isLessThan(LuaElement el,Object o1,Object o2) throws LuaException {
-		if( o1 instanceof LuaNumber && o2 instanceof LuaNumber ) {
-			LuaNumber n1 = (LuaNumber)o1;
-			LuaNumber n2 = (LuaNumber)o2;
-			return n1.compareTo(n2) < 0;
+		if( o1 instanceof Number && o2 instanceof Number ) {
+			Number n1 = (Number)o1;
+			Number n2 = (Number)o2;
+			return n1.doubleValue() < n2.doubleValue();
 		}
 		if( o1 instanceof String && o2 instanceof String ) {
 			String s1 = (String)o1;