This file contains hidden or 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
... | |
for (i = 0; i < size_b; ++i) { | |
carry += a->ob_digit[i] + b->ob_digit[i]; | |
z->ob_digit[i] = carry & PyLong_MASK; | |
carry >>= PyLong_SHIFT; | |
} | |
for (; i < size_a; ++i) { | |
carry += a->ob_digit[i]; | |
z->ob_digit[i] = carry & PyLong_MASK; | |
carry >>= PyLong_SHIFT; |
This file contains hidden or 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
struct _longobject { | |
PyObject ob_base; | |
Py_ssize_t ob_size; /* Number of items in variable part */ | |
digit ob_digit[1]; | |
}; |
This file contains hidden or 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
typedef struct { | |
PyObject ob_base; | |
Py_ssize_t ob_size; /* Number of items in variable part */ | |
} PyVarObject; |
This file contains hidden or 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
struct _longobject { | |
PyObject_VAR_HEAD | |
digit ob_digit[1]; | |
}; |
This file contains hidden or 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
>>> 2 ** 20000 | |
39802768403379665923543072061912024537047727804924259387134 ... | |
... | |
... 6021 digits long ... | |
... | |
6309376 |
This file contains hidden or 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
#include <stdio.h> | |
#include <math.h> | |
int main(void) { | |
printf("%Lf\n", powl(2, 20000)); | |
return 0; | |
} | |
$ ./a.out | |
inf |
This file contains hidden or 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
case TARGET(BINARY_ADD): { | |
PyObject *right = POP(); | |
PyObject *left = TOP(); | |
PyObject *result; | |
if (PyUnicode_CheckExact(left) && | |
PyUnicode_CheckExact(right)) { | |
result = unicode_concatenate(tstate, left, right, f, next_instr); | |
} | |
else { | |
// Do this operation only when both the operands are numbers and |
This file contains hidden or 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 '/': |
This file contains hidden or 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
int | |
get_random_number(int max) { | |
return time(NULL) % max; | |
} |
This file contains hidden or 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
if (PyNumber_Check(left) && PyNumber_Check(right)) { | |
// Both the operands are numbers | |
} |