diff -r 76e9c3e876d4 Doc/library/math.rst --- a/Doc/library/math.rst Sun May 29 20:46:27 2011 +0200 +++ b/Doc/library/math.rst Sun Jun 26 17:48:48 2011 +0900 @@ -33,9 +33,22 @@ .. function:: copysign(x, y) - Return *x* with the sign of *y*. On a platform that supports - signed zeros, ``copysign(1.0, -0.0)`` returns *-1.0*. + Return a float with the magnitude (absolute value) of *x* but the sign of + *y*. On platforms that supports signed zeros, ``copysign(1.0, -0.0)`` + returns *-1.0*. + in case the arguments are NaN + + >>> import math + >>> x = float('nan') + >>> math.copysign(1., x) + 1.0 + >>> math.copysign(-1., x) + 1.0 + >>> math.copysign(x, -1) + nan + >>> math.copysign(x, x) + nan .. function:: fabs(x) diff -r 76e9c3e876d4 Modules/mathmodule.c --- a/Modules/mathmodule.c Sun May 29 20:46:27 2011 +0200 +++ b/Modules/mathmodule.c Sun Jun 26 17:48:48 2011 +0900 @@ -905,7 +905,9 @@ "This is the smallest integral value >= x."); FUNC2(copysign, copysign, - "copysign(x, y)\n\nReturn x with the sign of y.") + "copysign(x, y)\n\nReturn a float with the magnitude (absolute value) " + "of x but the sign \nof y. On platforms that supports signed zeros, " + "copysign(1.0, -0.0) \nreturns -1.0.") FUNC1(cos, cos, 0, "cos(x)\n\nReturn the cosine of x (measured in radians).") FUNC1(cosh, cosh, 1,