This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients christian.heimes, mark.dickinson, rpetrov, skip.montanaro, tim.peters
Date 2009-01-04.22:57:09
SpamBayes Score 0.0067114425
Marked as misclassified No
Message-id <1231109830.06.0.642786551926.issue4575@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-01-04 22:57:10mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, skip.montanaro, christian.heimes, rpetrov
2009-01-04 22:57:10mark.dickinsonsetmessageid: <1231109830.06.0.642786551926.issue4575@psf.upfronthosting.co.za>
2009-01-04 22:57:09mark.dickinsonlinkissue4575 messages
2009-01-04 22:57:09mark.dickinsoncreate