[Python-checkins] r82608 - in python/branches/release27-maint: Modules/_math.c
mark.dickinson
python-checkins at python.org
Tue Jul 6 17:03:42 CEST 2010
Author: mark.dickinson
Date: Tue Jul 6 17:03:42 2010
New Revision: 82608
Log:
Merged revisions 82607 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r82607 | mark.dickinson | 2010-07-06 16:00:40 +0100 (Tue, 06 Jul 2010) | 1 line
Indentation and PEP 7 fixes.
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Modules/_math.c
Modified: python/branches/release27-maint/Modules/_math.c
==============================================================================
--- python/branches/release27-maint/Modules/_math.c (original)
+++ python/branches/release27-maint/Modules/_math.c Tue Jul 6 17:03:42 2010
@@ -55,7 +55,8 @@
else if (x >= two_pow_p28) { /* x > 2**28 */
if (Py_IS_INFINITY(x)) {
return x+x;
- } else {
+ }
+ else {
return log(x)+ln2; /* acosh(huge)=log(2x) */
}
}
@@ -173,15 +174,15 @@
*/
if (fabs(x) < 0.7) {
- double u;
- u = exp(x);
- if (u == 1.0)
- return x;
- else
- return (u - 1.0) * x / log(u);
+ double u;
+ u = exp(x);
+ if (u == 1.0)
+ return x;
+ else
+ return (u - 1.0) * x / log(u);
}
else
- return exp(x) - 1.0;
+ return exp(x) - 1.0;
}
/* log1p(x) = log(1+x). The log1p function is designed to avoid the
@@ -213,17 +214,19 @@
double y;
if (fabs(x) < DBL_EPSILON/2.) {
- return x;
- } else if (-0.5 <= x && x <= 1.) {
- /* WARNING: it's possible than an overeager compiler
- will incorrectly optimize the following two lines
- to the equivalent of "return log(1.+x)". If this
- happens, then results from log1p will be inaccurate
- for small x. */
- y = 1.+x;
- return log(y)-((y-1.)-x)/y;
- } else {
- /* NaNs and infinities should end up here */
- return log(1.+x);
+ return x;
+ }
+ else if (-0.5 <= x && x <= 1.) {
+ /* WARNING: it's possible than an overeager compiler
+ will incorrectly optimize the following two lines
+ to the equivalent of "return log(1.+x)". If this
+ happens, then results from log1p will be inaccurate
+ for small x. */
+ y = 1.+x;
+ return log(y)-((y-1.)-x)/y;
+ }
+ else {
+ /* NaNs and infinities should end up here */
+ return log(1.+x);
}
}
More information about the Python-checkins
mailing list