Message391883
There's an implicit float-to-double conversion here (`fp.contents.value` is represented as a Python float, which is backed by a C double). What you're seeing is that converting the single-precision signaling NaN to double precision loses the signaling bit, producing a quiet double-precision NaN with the same sign and payload (modulo the signaling bit). That's what I'd expect under IEEE 754 semantics. (IEEE 754-2008 says, in section 6.2, "Under default exception handling, any operation signaling an invalid operation exception and for which a floating-point result is to be delivered shall deliver a quiet NaN.".)
I don't think there's anything we can or should do about this at Python level. ctypes is correctly reflecting the existing C-level behaviour. In other words, this is expected behaviour, not a bug. |
|
Date |
User |
Action |
Args |
2021-04-26 07:40:59 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, steven.daprano, yang8621 |
2021-04-26 07:40:59 | mark.dickinson | set | messageid: <1619422859.56.0.313628438195.issue43940@roundup.psfhosted.org> |
2021-04-26 07:40:59 | mark.dickinson | link | issue43940 messages |
2021-04-26 07:40:58 | mark.dickinson | create | |
|