Fix for #260, float floor div
authorRobert Bradshaw <robertwb@math.washington.edu>
Sat, 28 Mar 2009 20:11:40 +0000 (13:11 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 28 Mar 2009 20:11:40 +0000 (13:11 -0700)
Cython/Compiler/ExprNodes.py

index 282ecb3c7dd356bcc75a2a8040356158cacbc5bd..89c5281e8f0de66bfaa9c832042543de6ebdf370 100644 (file)
@@ -4265,7 +4265,11 @@ class DivNode(NumBinopNode):
         code.putln("}")
     
     def calculate_result_code(self):
-        if self.cdivision:
+        if self.type.is_float and self.operator == '//':
+            return "floor(%s / %s)" % (
+                self.operand1.result(), 
+                self.operand2.result())
+        elif self.cdivision:
             return "(%s / %s)" % (
                 self.operand1.result(), 
                 self.operand2.result())