mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
bpo-44954: Fix wrong result in float.fromhex corner case (GH-27834)
This commit is contained in:
parent
d26dbba929
commit
60b93d9e49
3 changed files with 18 additions and 2 deletions
|
|
@ -1463,8 +1463,8 @@ float_fromhex(PyTypeObject *type, PyObject *string)
|
|||
bits lsb, lsb-2, lsb-3, lsb-4, ... is 1. */
|
||||
if ((digit & half_eps) != 0) {
|
||||
round_up = 0;
|
||||
if ((digit & (3*half_eps-1)) != 0 ||
|
||||
(half_eps == 8 && (HEX_DIGIT(key_digit+1) & 1) != 0))
|
||||
if ((digit & (3*half_eps-1)) != 0 || (half_eps == 8 &&
|
||||
key_digit+1 < ndigits && (HEX_DIGIT(key_digit+1) & 1) != 0))
|
||||
round_up = 1;
|
||||
else
|
||||
for (i = key_digit-1; i >= 0; i--)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue