Probably better links for this, but on MIPS, the floating point signalling bit seems typically inverted: https://sourceware.org/binutils/docs/as/MIPS-NaN-Encodings.html
However, Python's _Py_dg_stdnan should create quiet NaNs, but hard-codes the bit to 0.
This again continues to do weird things if mixed with NumPy apparently visible in some fmin downstream test failures (to be clear, I don't think the signalling bit should matter for that, but it is incorrect anyway; the bit should never be set in our part of the world). (See numpy/numpy#23158)
To me, all of that is a bit moot though. Python has this manual definition for NaN and Inf, but also defines Py_NAN and Py_HUGE_VAL. In theory, Py_HUGE_VAL doesn't need to be inf and Py_NAN I am not actually sure what it could be if NaN is not available...
But... If you have IEEE doubles and setting the bit-pattern manually is reasonable. You certainly can assume that both are defined to the right thing and Py_NAN is in fact a NaN value. Doing that simplifies the code, but should also solve the MIPS issue since Py_NAN presumably is correctly defined to a quiet NaN.
This is done in gh-104202. I suppose a test might be:
if hasattr(math, "nan"):
bits_nan1 = struct.pack("d", math.inf - math.inf)
bits_nan2 = struct.pack("d", math.nan)
assert bits_nan1 == bits_nan2
Probably better links for this, but on MIPS, the floating point signalling bit seems typically inverted: https://sourceware.org/binutils/docs/as/MIPS-NaN-Encodings.html
However, Python's _Py_dg_stdnan should create quiet NaNs, but hard-codes the bit to 0.
This again continues to do weird things if mixed with NumPy apparently visible in some
fmindownstream test failures (to be clear, I don't think the signalling bit should matter for that, but it is incorrect anyway; the bit should never be set in our part of the world). (See numpy/numpy#23158)To me, all of that is a bit moot though. Python has this manual definition for NaN and Inf, but also defines
Py_NANandPy_HUGE_VAL. In theory,Py_HUGE_VALdoesn't need to be inf andPy_NANI am not actually sure what it could be if NaN is not available...But... If you have IEEE doubles and setting the bit-pattern manually is reasonable. You certainly can assume that both are defined to the right thing and
Py_NANis in fact aNaNvalue. Doing that simplifies the code, but should also solve the MIPS issue sincePy_NANpresumably is correctly defined to a quiet NaN.This is done in gh-104202. I suppose a test might be: