Message79091
Tim, I'm in need of some advice on Py_IS_INFINITY. It's currently
implemented (on platforms that don't provide isinf) as
#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
I'd like to rewrite it as something like:
#define Py_IS_INFINITY_D(X) ((X) < -DBL_MAX || (X) > DBL_MAX)
#define Py_IS_INFINITY_F(X) ((X) < -FLT_MAX || (X) > FLT_MAX)
#define Py_IS_INFINITY(X) (sizeof(X) == sizeof(double) ? Py_IS_INFINITY_D(X) : Py_IS_INFINITY_F(X))
Are there any hidden (or obvious) numerical pitfalls with
this approach?
The reason for the rewrite is that the current Py_IS_INFINITY
can give false positives on x86 for values that are
pretending to be doubles, but are actually coming from an
80-bit x87 register. |
|
Date |
User |
Action |
Args |
2009-01-04 22:57:10 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, skip.montanaro, christian.heimes, rpetrov |
2009-01-04 22:57:10 | mark.dickinson | set | messageid: <1231109830.06.0.642786551926.issue4575@psf.upfronthosting.co.za> |
2009-01-04 22:57:09 | mark.dickinson | link | issue4575 messages |
2009-01-04 22:57:09 | mark.dickinson | create | |
|