Created
January 2, 2020 19:31
-
-
Save arpitbbhayani/ca62e68a31cb3d2b83637373ad00d4a9 to your computer and use it in GitHub Desktop.
Binary operate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PyObject * | |
binary_operate(PyObject * left, PyObject * right, char operator) { | |
switch (operator) { | |
case '+': | |
return PyNumber_Add(left, right); | |
case '-': | |
return PyNumber_Subtract(left, right); | |
case '*': | |
return PyNumber_Multiply(left, right); | |
case '/': | |
return PyNumber_FloorDivide(left, right); | |
case '^': | |
return PyNumber_Power(left, right, Py_None); | |
default: | |
return NULL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment