]> granicus.if.org Git - python/commit
The divmod function for large numbers now has an ACL2 proof. Related changes:
authorStefan Krah <skrah@bytereef.org>
Fri, 20 Apr 2012 17:59:20 +0000 (19:59 +0200)
committerStefan Krah <skrah@bytereef.org>
Fri, 20 Apr 2012 17:59:20 +0000 (19:59 +0200)
commit3c23a87e58ba5ba3161eaacae98a49a79e1f2786
tree73e77dafcdbf5282aba1691f19b3f5e4bed3590e
parenta2898c1d79ed3787d51a93a9ffb7c7c695b4a46e
The divmod function for large numbers now has an ACL2 proof. Related changes:

  1) Rename _mpd_qbarrett_divmod into _mpd_base_ndivmod: The function is
     only marginally related to either Barrett's algorithm or to the version
     in Hasselstrom's paper.

  2) In places where the proof assumes exact operations, use new versions of
     add/sub/multiply that set NaN/Invalid_operation if this condition is
     not met. According to the proof this cannot happen, so this should be
     regarded as an extra safety net.

  3) Raise Division_impossible for operands with a number of digits greater
     than MPD_MAX_PREC. This facilitates the audit of the function and can
     practically only occur in the 32-bit version under conditions where
     a MemoryError is already imminent.

  4) Use _mpd_qmul() in places where the result can exceed MPD_MAX_PREC in
     a well defined manner.

  5) Test for mpd_isspecial(qq) in a place where the addition of one
     can theoretically trigger a Malloc_error.

  6) Remove redundant code in _mpd_qdivmod().

  7) Add many comments.
Modules/_decimal/libmpdec/mpdecimal.c