Numworks Epsilon  1.4.1
Graphing Calculator Operating System
objint_mpz.c
Go to the documentation of this file.
1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2013, 2014 Damien P. George
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 
27 #include <string.h>
28 #include <stdio.h>
29 #include <assert.h>
30 
31 #include "py/parsenumbase.h"
32 #include "py/smallint.h"
33 #include "py/objint.h"
34 #include "py/runtime.h"
35 
36 #if MICROPY_PY_BUILTINS_FLOAT
37 #include <math.h>
38 #endif
39 
40 #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
41 
42 #if MICROPY_PY_SYS_MAXSIZE
43 // Export value for sys.maxsize
44 #define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1)
45 STATIC const mpz_dig_t maxsize_dig[] = {
46  #define NUM_DIG 1
48  #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 0) > DIG_MASK
49  #undef NUM_DIG
50  #define NUM_DIG 2
52  #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 1) > DIG_MASK
53  #undef NUM_DIG
54  #define NUM_DIG 3
56  #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 2) > DIG_MASK
57  #undef NUM_DIG
58  #define NUM_DIG 4
60  #if (MP_SSIZE_MAX >> MPZ_DIG_SIZE * 3) > DIG_MASK
61  #error cannot encode MP_SSIZE_MAX as mpz
62  #endif
63  #endif
64  #endif
65  #endif
66 };
68  {&mp_type_int},
69  {.fixed_dig = 1, .len = NUM_DIG, .alloc = NUM_DIG, .dig = (mpz_dig_t*)maxsize_dig}
70 };
71 #undef DIG_MASK
72 #undef NUM_DIG
73 #endif
74 
77  o->base.type = &mp_type_int;
78  mpz_init_zero(&o->mpz);
79  return o;
80 }
81 
82 // This routine expects you to pass in a buffer and size (in *buf and buf_size).
83 // If, for some reason, this buffer is too small, then it will allocate a
84 // buffer and return the allocated buffer and size in *buf and *buf_size. It
85 // is the callers responsibility to free this allocated buffer.
86 //
87 // The resulting formatted string will be returned from this function and the
88 // formatted size will be in *fmt_size.
89 //
90 // This particular routine should only be called for the mpz representation of the int.
91 char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
92  int base, const char *prefix, char base_char, char comma) {
93  assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
94  const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
95 
96  size_t needed_size = mp_int_format_size(mpz_max_num_bits(&self->mpz), base, prefix, comma);
97  if (needed_size > *buf_size) {
98  *buf = m_new(char, needed_size);
99  *buf_size = needed_size;
100  }
101  char *str = *buf;
102 
103  *fmt_size = mpz_as_str_inpl(&self->mpz, base, prefix, base_char, comma, str);
104 
105  return str;
106 }
107 
108 mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf) {
110  mpz_set_from_bytes(&o->mpz, big_endian, len, buf);
111  return MP_OBJ_FROM_PTR(o);
112 }
113 
114 void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf) {
115  assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
116  mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
117  memset(buf, 0, len);
118  mpz_as_bytes(&self->mpz, big_endian, len, buf);
119 }
120 
121 int mp_obj_int_sign(mp_obj_t self_in) {
122  if (MP_OBJ_IS_SMALL_INT(self_in)) {
123  mp_int_t val = MP_OBJ_SMALL_INT_VALUE(self_in);
124  if (val < 0) {
125  return -1;
126  } else if (val > 0) {
127  return 1;
128  } else {
129  return 0;
130  }
131  }
132  mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
133  if (self->mpz.len == 0) {
134  return 0;
135  } else if (self->mpz.neg == 0) {
136  return 1;
137  } else {
138  return -1;
139  }
140 }
141 
143  mp_obj_int_t *o = MP_OBJ_TO_PTR(o_in);
144  switch (op) {
145  case MP_UNARY_OP_BOOL: return mp_obj_new_bool(!mpz_is_zero(&o->mpz));
146  case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mpz_hash(&o->mpz));
147  case MP_UNARY_OP_POSITIVE: return o_in;
148  case MP_UNARY_OP_NEGATIVE: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_neg_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); }
149  case MP_UNARY_OP_INVERT: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_not_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); }
150  case MP_UNARY_OP_ABS: {
151  mp_obj_int_t *self = MP_OBJ_TO_PTR(o_in);
152  if (self->mpz.neg == 0) {
153  return o_in;
154  }
155  mp_obj_int_t *self2 = mp_obj_int_new_mpz();
156  mpz_abs_inpl(&self2->mpz, &self->mpz);
157  return MP_OBJ_FROM_PTR(self2);
158  }
159  default: return MP_OBJ_NULL; // op not supported
160  }
161 }
162 
164  const mpz_t *zlhs;
165  const mpz_t *zrhs;
166  mpz_t z_int;
167  mpz_dig_t z_int_dig[MPZ_NUM_DIG_FOR_INT];
168 
169  // lhs could be a small int (eg small-int + mpz)
170  if (MP_OBJ_IS_SMALL_INT(lhs_in)) {
172  zlhs = &z_int;
173  } else if (MP_OBJ_IS_TYPE(lhs_in, &mp_type_int)) {
174  zlhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(lhs_in))->mpz;
175  } else {
176  // unsupported type
177  return MP_OBJ_NULL;
178  }
179 
180  // if rhs is small int, then lhs was not (otherwise mp_binary_op handles it)
181  if (MP_OBJ_IS_SMALL_INT(rhs_in)) {
183  zrhs = &z_int;
184  } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_int)) {
185  zrhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(rhs_in))->mpz;
186 #if MICROPY_PY_BUILTINS_FLOAT
187  } else if (mp_obj_is_float(rhs_in)) {
188  return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in);
189 #if MICROPY_PY_BUILTINS_COMPLEX
190  } else if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) {
191  return mp_obj_complex_binary_op(op, mpz_as_float(zlhs), 0, rhs_in);
192 #endif
193 #endif
194  } else {
195  // delegate to generic function to check for extra cases
196  return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in);
197  }
198 
199  if (0) {
200 #if MICROPY_PY_BUILTINS_FLOAT
202  if (mpz_is_zero(zrhs)) {
203  goto zero_division_error;
204  }
205  mp_float_t flhs = mpz_as_float(zlhs);
206  mp_float_t frhs = mpz_as_float(zrhs);
207  return mp_obj_new_float(flhs / frhs);
208 #endif
209 
210  } else if (op >= MP_BINARY_OP_INPLACE_OR) {
212 
213  switch (op) {
214  case MP_BINARY_OP_ADD:
216  mpz_add_inpl(&res->mpz, zlhs, zrhs);
217  break;
220  mpz_sub_inpl(&res->mpz, zlhs, zrhs);
221  break;
224  mpz_mul_inpl(&res->mpz, zlhs, zrhs);
225  break;
228  if (mpz_is_zero(zrhs)) {
229  zero_division_error:
230  mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
231  }
232  mpz_t rem; mpz_init_zero(&rem);
233  mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs);
234  mpz_deinit(&rem);
235  break;
236  }
237  case MP_BINARY_OP_MODULO:
239  if (mpz_is_zero(zrhs)) {
240  goto zero_division_error;
241  }
242  mpz_t quo; mpz_init_zero(&quo);
243  mpz_divmod_inpl(&quo, &res->mpz, zlhs, zrhs);
244  mpz_deinit(&quo);
245  break;
246  }
247 
248  case MP_BINARY_OP_AND:
250  mpz_and_inpl(&res->mpz, zlhs, zrhs);
251  break;
252  case MP_BINARY_OP_OR:
254  mpz_or_inpl(&res->mpz, zlhs, zrhs);
255  break;
256  case MP_BINARY_OP_XOR:
258  mpz_xor_inpl(&res->mpz, zlhs, zrhs);
259  break;
260 
261  case MP_BINARY_OP_LSHIFT:
263  case MP_BINARY_OP_RSHIFT:
265  mp_int_t irhs = mp_obj_int_get_checked(rhs_in);
266  if (irhs < 0) {
267  mp_raise_ValueError("negative shift count");
268  }
270  mpz_shl_inpl(&res->mpz, zlhs, irhs);
271  } else {
272  mpz_shr_inpl(&res->mpz, zlhs, irhs);
273  }
274  break;
275  }
276 
277  case MP_BINARY_OP_POWER:
279  if (mpz_is_neg(zrhs)) {
280  #if MICROPY_PY_BUILTINS_FLOAT
281  return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in);
282  #else
283  mp_raise_ValueError("negative power with no float support");
284  #endif
285  }
286  mpz_pow_inpl(&res->mpz, zlhs, zrhs);
287  break;
288 
289  default: {
291  if (mpz_is_zero(zrhs)) {
292  goto zero_division_error;
293  }
295  mpz_divmod_inpl(&quo->mpz, &res->mpz, zlhs, zrhs);
296  mp_obj_t tuple[2] = {MP_OBJ_FROM_PTR(quo), MP_OBJ_FROM_PTR(res)};
297  return mp_obj_new_tuple(2, tuple);
298  }
299  }
300 
301  return MP_OBJ_FROM_PTR(res);
302 
303  } else {
304  int cmp = mpz_cmp(zlhs, zrhs);
305  switch (op) {
306  case MP_BINARY_OP_LESS:
307  return mp_obj_new_bool(cmp < 0);
308  case MP_BINARY_OP_MORE:
309  return mp_obj_new_bool(cmp > 0);
311  return mp_obj_new_bool(cmp <= 0);
313  return mp_obj_new_bool(cmp >= 0);
314  case MP_BINARY_OP_EQUAL:
315  return mp_obj_new_bool(cmp == 0);
316 
317  default:
318  return MP_OBJ_NULL; // op not supported
319  }
320  }
321 }
322 
323 #if MICROPY_PY_BUILTINS_POW3
324 STATIC mpz_t *mp_mpz_for_int(mp_obj_t arg, mpz_t *temp) {
325  if (MP_OBJ_IS_SMALL_INT(arg)) {
327  return temp;
328  } else {
329  mp_obj_int_t *arp_p = MP_OBJ_TO_PTR(arg);
330  return &(arp_p->mpz);
331  }
332 }
333 
334 mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus) {
335  if (!MP_OBJ_IS_INT(base) || !MP_OBJ_IS_INT(exponent) || !MP_OBJ_IS_INT(modulus)) {
336  mp_raise_TypeError("pow() with 3 arguments requires integers");
337  } else {
338  mp_obj_t result = mp_obj_new_int_from_ull(0); // Use the _from_ull version as this forces an mpz int
339  mp_obj_int_t *res_p = (mp_obj_int_t *) MP_OBJ_TO_PTR(result);
340 
341  mpz_t l_temp, r_temp, m_temp;
342  mpz_t *lhs = mp_mpz_for_int(base, &l_temp);
343  mpz_t *rhs = mp_mpz_for_int(exponent, &r_temp);
344  mpz_t *mod = mp_mpz_for_int(modulus, &m_temp);
345 
346  mpz_pow3_inpl(&(res_p->mpz), lhs, rhs, mod);
347 
348  if (lhs == &l_temp) { mpz_deinit(lhs); }
349  if (rhs == &r_temp) { mpz_deinit(rhs); }
350  if (mod == &m_temp) { mpz_deinit(mod); }
351  return result;
352  }
353 }
354 #endif
355 
357  if (MP_SMALL_INT_FITS(value)) {
358  return MP_OBJ_NEW_SMALL_INT(value);
359  }
360  return mp_obj_new_int_from_ll(value);
361 }
362 
365  mpz_set_from_ll(&o->mpz, val, true);
366  return MP_OBJ_FROM_PTR(o);
367 }
368 
369 mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
371  mpz_set_from_ll(&o->mpz, val, false);
372  return MP_OBJ_FROM_PTR(o);
373 }
374 
376  // SMALL_INT accepts only signed numbers, so make sure the input
377  // value fits completely in the small-int positive range.
378  if ((value & ~MP_SMALL_INT_POSITIVE_MASK) == 0) {
379  return MP_OBJ_NEW_SMALL_INT(value);
380  }
381  return mp_obj_new_int_from_ull(value);
382 }
383 
384 mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base) {
386  size_t n = mpz_set_from_str(&o->mpz, *str, len, neg, base);
387  *str += n;
388  return MP_OBJ_FROM_PTR(o);
389 }
390 
392  if (MP_OBJ_IS_SMALL_INT(self_in)) {
393  return MP_OBJ_SMALL_INT_VALUE(self_in);
394  } else {
395  const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
396  // hash returns actual int value if it fits in mp_int_t
397  return mpz_hash(&self->mpz);
398  }
399 }
400 
402  if (MP_OBJ_IS_SMALL_INT(self_in)) {
403  return MP_OBJ_SMALL_INT_VALUE(self_in);
404  } else {
405  const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
406  mp_int_t value;
407  if (mpz_as_int_checked(&self->mpz, &value)) {
408  return value;
409  } else {
410  // overflow
411  mp_raise_msg(&mp_type_OverflowError, "overflow converting long int to machine word");
412  }
413  }
414 }
415 
416 #if MICROPY_PY_BUILTINS_FLOAT
417 mp_float_t mp_obj_int_as_float_impl(mp_obj_t self_in) {
418  assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
419  mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
420  return mpz_as_float(&self->mpz);
421 }
422 #endif
423 
424 #endif
void mpz_deinit(mpz_t *z)
Definition: mpz.c:670
void mpz_init_zero(mpz_t *z)
Definition: mpz.c:648
intptr_t mp_int_t
Definition: mpconfigport.h:73
uintptr_t mp_uint_t
Definition: mpconfigport.h:74
void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1288
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg)
Definition: runtime.c:1448
void * memset(void *b, int c, size_t len)
Definition: memset.c:3
int mp_obj_int_sign(mp_obj_t self_in)
Definition: objint_mpz.c:121
mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items)
Definition: objtuple.c:235
#define assert(e)
Definition: assert.h:9
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value)
Definition: objint_mpz.c:375
const mp_obj_type_t mp_type_ZeroDivisionError
mp_obj_base_t base
Definition: objint.h:33
void mpz_set_from_ll(mpz_t *z, long long val, bool is_signed)
Definition: mpz.c:782
#define MP_OBJ_IS_TYPE(o, t)
Definition: obj.h:254
void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf)
Definition: mpz.c:909
void mpz_mul_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1326
mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
Definition: objint.c:373
size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base)
Definition: mpz.c:873
void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1171
#define MP_OBJ_FROM_PTR(p)
Definition: obj.h:233
void mpz_pow3_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod)
Definition: mpz.c:1392
mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in)
Definition: objint_mpz.c:142
mp_unary_op_t
Definition: runtime0.h:45
mp_obj_t mp_obj_new_int(mp_int_t value)
Definition: objint_mpz.c:356
#define STATIC
Definition: mpconfig.h:1178
#define MP_OBJ_SMALL_INT_VALUE(o)
Definition: obj.h:86
#define mp_obj_is_float(o)
Definition: obj.h:745
size_t mp_int_format_size(size_t num_bits, int base, const char *prefix, char comma)
Definition: objint.c:207
mp_int_t mpz_hash(const mpz_t *z)
Definition: mpz.c:1561
void mpz_as_bytes(const mpz_t *z, bool big_endian, size_t len, byte *buf)
Definition: mpz.c:1618
void mpz_init_from_int(mpz_t *z, mp_int_t val)
Definition: mpz.c:656
const mp_obj_type_t mp_type_complex
Definition: mpz.h:89
#define MP_OBJ_NEW_SMALL_INT(small_int)
Definition: obj.h:87
uint16_t mpz_dig_t
Definition: mpz.h:62
#define DIG_MASK
Definition: mpz.c:35
uint64_t mp_const_obj_t
Definition: obj.h:40
void mpz_shr_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs)
Definition: mpz.c:1133
#define MP_OBJ_NULL
Definition: obj.h:73
mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in)
Definition: objint_mpz.c:391
void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1220
#define MP_SMALL_INT_FITS(n)
Definition: smallint.h:40
void mpz_neg_inpl(mpz_t *dest, const mpz_t *z)
Definition: mpz.c:1086
mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
Definition: objint_mpz.c:163
#define MPZ_DIG_SIZE
Definition: mpz.h:53
mp_binary_op_t
Definition: runtime0.h:67
void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1192
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val)
Definition: objint_mpz.c:369
void mpz_pow_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1358
#define MP_OBJ_IS_INT(o)
Definition: obj.h:255
void mpz_abs_inpl(mpz_t *dest, const mpz_t *z)
Definition: mpz.c:1076
mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in)
Definition: objint_mpz.c:401
unsigned char byte
Definition: misc.h:37
char * mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in, int base, const char *prefix, char base_char, char comma)
Definition: objint_mpz.c:91
int mpz_cmp(const mpz_t *z1, const mpz_t *z2)
Definition: mpz.c:958
NORETURN void mp_raise_ValueError(const char *msg)
Definition: runtime.c:1456
mp_obj_int_t * mp_obj_int_new_mpz(void)
Definition: objint_mpz.c:75
mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base)
Definition: objint_mpz.c:384
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf)
Definition: objint_mpz.c:108
void mpz_shl_inpl(mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs)
Definition: mpz.c:1120
void mpz_or_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1254
void mpz_init_fixed_from_int(mpz_t *z, mpz_dig_t *dig, size_t alloc, mp_int_t val)
Definition: mpz.c:661
#define MP_OBJ_TO_PTR(o)
Definition: obj.h:228
bool mpz_as_int_checked(const mpz_t *i, mp_int_t *value)
Definition: mpz.c:1576
const mp_obj_int_t mp_maxsize_obj
mp_obj_t mp_obj_new_int_from_ll(long long val)
Definition: objint_mpz.c:363
#define MP_SSIZE_MAX
Definition: mpconfig.h:1247
#define MPZ_NUM_DIG_FOR_INT
Definition: mpz.h:86
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf)
Definition: objint_mpz.c:114
uint64_t mp_obj_t
Definition: obj.h:39
const mp_obj_type_t mp_type_int
Definition: obj.h:544
NORETURN void mp_raise_TypeError(const char *msg)
Definition: runtime.c:1460
#define m_new_obj(type)
Definition: misc.h:60
#define MP_SMALL_INT_POSITIVE_MASK
Definition: smallint.h:42
size_t mpz_as_str_inpl(const mpz_t *i, unsigned int base, const char *prefix, char base_char, char comma, char *str)
Definition: mpz.c:1679
const mp_obj_type_t mp_type_OverflowError
void mpz_not_inpl(mpz_t *dest, const mpz_t *z)
Definition: mpz.c:1096
#define m_new(type, num)
Definition: misc.h:57
void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs)
Definition: mpz.c:1513
mp_obj_t mp_obj_int_pow3(mp_obj_t base, mp_obj_t exponent, mp_obj_t modulus)