Merge pull request #110 from khinsen/integer_division
Implement integer division operator
This commit is contained in:
commit
a729b52155
@ -708,6 +708,7 @@ class HyASTCompiler(object):
|
|||||||
@builds("%")
|
@builds("%")
|
||||||
@builds("-")
|
@builds("-")
|
||||||
@builds("/")
|
@builds("/")
|
||||||
|
@builds("//")
|
||||||
@builds("*")
|
@builds("*")
|
||||||
@checkargs(min=2)
|
@checkargs(min=2)
|
||||||
def compile_maths_expression(self, expression):
|
def compile_maths_expression(self, expression):
|
||||||
@ -717,6 +718,7 @@ class HyASTCompiler(object):
|
|||||||
|
|
||||||
ops = {"+": ast.Add,
|
ops = {"+": ast.Add,
|
||||||
"/": ast.Div,
|
"/": ast.Div,
|
||||||
|
"//": ast.FloorDiv,
|
||||||
"*": ast.Mult,
|
"*": ast.Mult,
|
||||||
"-": ast.Sub,
|
"-": ast.Sub,
|
||||||
"%": ast.Mod}
|
"%": ast.Mod}
|
||||||
|
@ -29,6 +29,10 @@
|
|||||||
"NATIVE: Test division"
|
"NATIVE: Test division"
|
||||||
(assert (= 25 (/ 100 2 2)))))
|
(assert (= 25 (/ 100 2 2)))))
|
||||||
|
|
||||||
|
(setv test_int_div (fn []
|
||||||
|
"NATIVE: Test integer division"
|
||||||
|
(assert (= 25 (// 101 2 2)))))
|
||||||
|
|
||||||
(defn test-modulo []
|
(defn test-modulo []
|
||||||
"NATIVE: test mod"
|
"NATIVE: test mod"
|
||||||
(assert (= (% 10 2) 0)))
|
(assert (= (% 10 2) 0)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user