- May 21, 2018
-
-
Jeff Epler authored
Before this, ubsan would detect a problem when executing hash(006699999999999999999999999999999999999999999999999999999999999999999999) ../../py/mpz.c:1539:20: runtime error: left shift of 1067371580458 by 32 places cannot be represented in type 'mp_int_t' (aka 'long') When the overflow does occur it now happens as defined by the rules of unsigned arithmetic.
-
- Feb 25, 2018
-
-
Damien George authored
This path for src->deg==NULL is never used because mpz_clone() is always called with an argument that has a non-zero integer value, and hence has some digits allocated to it (mpz_clone() is a static function private to mpz.c all callers of this function first check if the integer value is zero and if so take a special-case path, bypassing the call to mpz_clone()). There is some unused and commented-out functions that may actually pass a zero-valued mpz to mpz_clone(), so some TODOs are added to these function in case they are needed in the future.
-
- Dec 29, 2017
-
-
Damien George authored
There are two checks that are always false so can be converted to (negated) assertions to save code space and execution time. They are: 1. The check of the str parameter, which is required to be non-NULL as per the original comment that it has enough space in it as calculated by mp_int_format_size. And for all uses of this function str is indeed non-NULL. 2. The check of the base parameter, which is already required to be between 2 and 16 (inclusive) via the assertion in mp_int_format_size.
-
Damien George authored
The motivation behind this patch is to remove unreachable code in mpn_div. This unreachable code was added some time ago in 9a21d2e0, when a loop in mpn_div was copied and adjusted to work when mpz_dig_t was exactly half of the size of mpz_dbl_dig_t (a common case). The loop was copied correctly but it wasn't noticed at the time that the final part of the calculation of num-quo*den could be optimised, and hence unreachable code was left for a case that never occurred. The observation for the optimisation is that the initial value of quo in mpn_div is either exact or too large (never too small), and therefore the subtraction of quo*den from num may subtract exactly enough or too much (but never too little). Using this observation the part of the algorithm that handles the borrow value can be simplified, and most importantly this eliminates the unreachable code. The new code has been tested with DIG_SIZE=3 and DIG_SIZE=4 by dividing all possible combinations of non-negative integers with between 0 and 3 (inclusive) mpz digits.
-
- Dec 19, 2017
-
-
Damien George authored
-
Damien George authored
In this case the result should always be 0, even if 2nd arg is 0.
-
- Jul 31, 2017
-
-
Alexander Steffen authored
There were several different spellings of MicroPython present in comments, when there should be only one.
-
- Jul 25, 2017
-
-
Damien George authored
Before this patch raising a big-int to a negative power would just return 0. Now it returns a floating-point number with the correct value.
-
Damien George authored
It's more efficient as an inline function, and saves code size.
-
- Apr 25, 2017
-
-
Damien George authored
-
Damien George authored
-
- Feb 16, 2017
-
-
Damien George authored
-
Damien George authored
-
Damien George authored
-
- Feb 02, 2017
-
-
Nicko van Someren authored
Updated modbuiltin.c to add conditional support for 3-arg calls to pow() using MICROPY_PY_BUILTINS_POW3 config parameter. Added support in objint_mpz.c for for optimised implementation.
-
- Jan 21, 2017
-
-
Paul Sokolovsky authored
-
- Dec 28, 2016
-
-
Damien George authored
-
- Dec 13, 2016
-
-
Damien George authored
-
- Oct 31, 2016
-
-
Pavol Rusnak authored
-
- Oct 11, 2016
-
-
Damien George authored
-
Damien George authored
-
Damien George authored
The check for division by zero is made by the caller of this function.
-
- May 09, 2016
-
-
Damien George authored
Previous to this patch bignum division and modulo would temporarily modify the RHS argument to the operation (eg x/y would modify y), but on return the RHS would be restored to its original value. This is not allowed because arguments to binary operations are const, and in particular might live in ROM. The modification was to normalise the arg (and then unnormalise before returning), and this patch makes it so the normalisation is done on the fly and the arg is now accessed as read-only. This change doesn't increase the order complexity of the operation, and actually reduces code size.
-
- May 08, 2016
-
-
Damien George authored
This patch consolidates the Python logic for division/modulo to one place within the bignum code.
-
Damien George authored
When DIG_SIZE=32, a uint32_t is used to store limbs, and no normalisation is needed because the MSB is already set, then there will be left and right shifts (in C) by 32 of a 32-bit variable, leading to undefined behaviour. This patch fixes this bug.
-
- Feb 03, 2016
-
-
Damien George authored
This function computes (x**y)%z in an efficient way. For large arguments this operation is otherwise not computable by doing x**y and then %z. It's currently not used, but is added in case it's useful one day.
-
Doug Currie authored
For these 3 bitwise operations there are now fast functions for positive-only arguments, and general functions for arbitrary sign arguments (the fast functions are the existing implementation). By default the fast functions are not used (to save space) and instead the general functions are used for all operations. Enable MICROPY_OPT_MPZ_BITWISE to use the fast functions for positive arguments.
-
- Jan 08, 2016
-
-
Damien George authored
-
- Nov 22, 2015
-
-
Paul Sokolovsky authored
-
- Oct 01, 2015
-
-
Damien George authored
-
Damien George authored
Python semantics are that rhs of shift must be non-negative, so there's no need to handle negative values in the underlying mpz implementation.
-
Damien George authored
-
- Apr 25, 2015
-
-
Damien George authored
-
Damien George authored
This gets int.to_bytes working for bignum, and also struct.pack with 'q' and 'Q' args on 32-bit machines. Addresses issue #1155.
-
- Apr 22, 2015
-
-
Damien George authored
-
- Apr 09, 2015
-
-
Damien George authored
-
- Mar 12, 2015
-
-
Damien George authored
-
- Mar 02, 2015
-
-
Damien George authored
-
- Jan 27, 2015
-
-
Damien George authored
-
- Jan 24, 2015
-
-
David Steinberg authored
-