Skip to content

Commit d0254b0

Browse files
committed
address review: comments on handling NaN's
1 parent 44e602d commit d0254b0

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Objects/floatobject.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,9 @@ PyFloat_Pack2(double x, char *data, int le)
18961896
{
18971897
unsigned char *p = (unsigned char *)data;
18981898
#if HAVE_FLOAT16
1899+
/* Conversion can change NaNs type or alter payload. Here we
1900+
just fallback to the generic code, instead of providing
1901+
workarounds as for single/double precision. */
18991902
if (!isnan(x)) {
19001903
_Float16 y = (_Float16)x;
19011904

@@ -2128,6 +2131,7 @@ PyFloat_Unpack2(const char *data, int le)
21282131
if (!isnan(x16)) {
21292132
return x16;
21302133
}
2134+
/* Fallback to the generic code for NaNs, see PyFloat_Pack2(). */
21312135
#endif
21322136
unsigned char sign;
21332137
int e;

0 commit comments

Comments
 (0)