mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-130317: Fix test_pack_unpack_roundtrip() and add docs (#133204)
* Skip sNaN's testing in 32-bit mode. * Drop float_set_snan() helper. * Use memcpy() workaround for sNaN's in PyFloat_Unpack4(). * Document, that sNaN's may not be preserved by PyFloat_Pack/Unpack API.
This commit is contained in:
parent
ed039b801d
commit
ad2f0884b1
5 changed files with 18 additions and 62 deletions
|
@ -2495,12 +2495,10 @@ PyFloat_Unpack4(const char *data, int le)
|
|||
|
||||
if ((v & (1 << 22)) == 0) {
|
||||
double y = x; /* will make qNaN double */
|
||||
union double_val {
|
||||
double d;
|
||||
uint64_t u64;
|
||||
} *py = (union double_val *)&y;
|
||||
|
||||
py->u64 &= ~(1ULL << 51); /* make sNaN */
|
||||
uint64_t u64;
|
||||
memcpy(&u64, &y, 8);
|
||||
u64 &= ~(1ULL << 51); /* make sNaN */
|
||||
memcpy(&y, &u64, 8);
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue