[New-bugs-announce] [issue42210] float.hex discards sign from -nan

Sree report at bugs.python.org
Fri Oct 30 12:04:29 EDT 2020


New submission from Sree <sree314 at gmail.com>:

float.hex(float.fromhex("-nan")) returns 'nan'.

PyOS_double_to_string seems to check only if it is a NaN, but ignores the sign (unlike its handling of inf a few lines below):

<https://github.com/python/cpython/blob/e9e7d284c434768333fdfb53a3663eae74cb995a/Python/pystrtod.c#L903>

Issue 5981 (https://bugs.python.org/issue5981) added the ability for fromhex to recognize -nan, but hex should probably have been updated at the same time.

Encountered when testing float implementations.

----------
components: Interpreter Core
messages: 379979
nosy: sree314
priority: normal
severity: normal
status: open
title: float.hex discards sign from -nan
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42210>
_______________________________________


More information about the New-bugs-announce mailing list