Skip to content

Commit

Permalink
Fix size of cached powers of 5 array.
Browse files Browse the repository at this point in the history
We need the powers of 5 up to 5**512 because we only jump straight to
underflow when the exponent is less than -512 (or larger than 308).
  • Loading branch information
colesbury committed Nov 13, 2023
1 parent b54b649 commit 4fd7747
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Include/internal/pycore_dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct _dtoa_state {
#define Bigint_Kmax 7

/* The size of the cached powers of 5 array */
#define Bigint_Pow5max 7
#define Bigint_Pow5max 8

#ifndef PRIVATE_MEM
#define PRIVATE_MEM 2304
Expand Down
2 changes: 1 addition & 1 deletion Python/dtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,7 @@ _PyDtoa_Init(PyInterpreterState *interp)
}
p5s[0] = p5;

// compute 5**8, 5**16, 5**32, ..., 5**256
// compute 5**8, 5**16, 5**32, ..., 5**512
for (Py_ssize_t i = 1; i < Bigint_Pow5max; i++) {
p5 = mult(p5, p5);
if (p5 == NULL) {
Expand Down

0 comments on commit 4fd7747

Please sign in to comment.