~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Include/pymath.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-10-03 12:03:05 UTC
  • mto: (10.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091003120305-hij6yssh0figh590
Tags: upstream-2.6.3
ImportĀ upstreamĀ versionĀ 2.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
#define Py_MATH_E 2.7182818284590452354
78
78
#endif
79
79
 
 
80
/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU
 
81
   register and into a 64-bit memory location, rounding from extended
 
82
   precision to double precision in the process.  On other platforms it does
 
83
   nothing. */
 
84
 
 
85
/* we take double rounding as evidence of x87 usage */
 
86
#ifndef Py_FORCE_DOUBLE
 
87
#  ifdef X87_DOUBLE_ROUNDING
 
88
PyAPI_FUNC(double) _Py_force_double(double);
 
89
#    define Py_FORCE_DOUBLE(X) (_Py_force_double(X))
 
90
#  else
 
91
#    define Py_FORCE_DOUBLE(X) (X)
 
92
#  endif
 
93
#endif
 
94
 
80
95
/* Py_IS_NAN(X)
81
96
 * Return 1 if float or double arg is a NaN, else 0.
82
97
 * Caution:
87
102
 * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan
88
103
 */
89
104
#ifndef Py_IS_NAN
90
 
#ifdef HAVE_ISNAN
 
105
#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1
91
106
#define Py_IS_NAN(X) isnan(X)
92
107
#else
93
108
#define Py_IS_NAN(X) ((X) != (X))
101
116
 *    This implementation may set the underflow flag if |X| is very small;
102
117
 *    it really can't be implemented correctly (& easily) before C99.
103
118
 *    Override in pyconfig.h if you have a better spelling on your platform.
 
119
 *  Py_FORCE_DOUBLE is used to avoid getting false negatives from a
 
120
 *    non-infinite value v sitting in an 80-bit x87 register such that
 
121
 *    v becomes infinite when spilled from the register to 64-bit memory.
104
122
 * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
105
123
 */
106
124
#ifndef Py_IS_INFINITY
107
 
#ifdef HAVE_ISINF
108
 
#define Py_IS_INFINITY(X) isinf(X)
109
 
#else
110
 
#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
111
 
#endif
 
125
#  if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1
 
126
#    define Py_IS_INFINITY(X) isinf(X)
 
127
#  else
 
128
#    define Py_IS_INFINITY(X) ((X) &&                                   \
 
129
                               (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))
 
130
#  endif
112
131
#endif
113
132
 
114
133
/* Py_IS_FINITE(X)
118
137
 * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite
119
138
 */
120
139
#ifndef Py_IS_FINITE
121
 
#ifdef HAVE_FINITE
 
140
#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1
 
141
#define Py_IS_FINITE(X) isfinite(X)
 
142
#elif defined HAVE_FINITE
122
143
#define Py_IS_FINITE(X) finite(X)
123
144
#else
124
145
#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))