Skip to content
Snippets Groups Projects
Select Git revision
  • dualcore
  • ch3/leds
  • wip-bootstrap default
  • ch3/time
  • master
5 results

mpz.c

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