Mercurial Hosting > luan
diff src/luan/impl/LuanImpl.java @ 1680:9ef19f5ea973
add // operator
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 02 Jun 2022 22:34:55 -0600 |
parents | c922446f53aa |
children |
line wrap: on
line diff
--- a/src/luan/impl/LuanImpl.java Tue May 31 15:39:58 2022 -0600 +++ b/src/luan/impl/LuanImpl.java Thu Jun 02 22:34:55 2022 -0600 @@ -67,6 +67,15 @@ return arithmetic(luan,"__div",o1,o2); } + public static Object idiv(Luan luan,Object o1,Object o2) throws LuanException { + if( o1 instanceof Number && o2 instanceof Number ) { + double d1 = ((Number)o1).doubleValue(); + double d2 = ((Number)o2).doubleValue(); + return Math.floor(d1/d2); + } + return arithmetic(luan,"__idiv",o1,o2); + } + public static Object mod(Luan luan,Object o1,Object o2) throws LuanException { if( o1 instanceof Number && o2 instanceof Number ) { double d1 = ((Number)o1).doubleValue();