Skip to content
  • Damien George's avatar
    py/mpz: Fix mpn_div so that it doesn't modify memory of denominator. · 460b0863
    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.
    460b0863