comparison 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
comparison
equal deleted inserted replaced
1679:39287902fb0c 1680:9ef19f5ea973
63 63
64 public static Object div(Luan luan,Object o1,Object o2) throws LuanException { 64 public static Object div(Luan luan,Object o1,Object o2) throws LuanException {
65 if( o1 instanceof Number && o2 instanceof Number ) 65 if( o1 instanceof Number && o2 instanceof Number )
66 return ((Number)o1).doubleValue() / ((Number)o2).doubleValue(); 66 return ((Number)o1).doubleValue() / ((Number)o2).doubleValue();
67 return arithmetic(luan,"__div",o1,o2); 67 return arithmetic(luan,"__div",o1,o2);
68 }
69
70 public static Object idiv(Luan luan,Object o1,Object o2) throws LuanException {
71 if( o1 instanceof Number && o2 instanceof Number ) {
72 double d1 = ((Number)o1).doubleValue();
73 double d2 = ((Number)o2).doubleValue();
74 return Math.floor(d1/d2);
75 }
76 return arithmetic(luan,"__idiv",o1,o2);
68 } 77 }
69 78
70 public static Object mod(Luan luan,Object o1,Object o2) throws LuanException { 79 public static Object mod(Luan luan,Object o1,Object o2) throws LuanException {
71 if( o1 instanceof Number && o2 instanceof Number ) { 80 if( o1 instanceof Number && o2 instanceof Number ) {
72 double d1 = ((Number)o1).doubleValue(); 81 double d1 = ((Number)o1).doubleValue();