NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/44057: tanh() function doesn't preserve the zero sign



>Number:         44057
>Category:       lib
>Synopsis:       tanh() function doesn't preserve the zero sign
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 07 14:30:00 +0000 2010
>Originator:     Victor Stinner
>Release:        5.0.x
>Organization:
>Environment:
"NetBSD 5.0.x i386", sorry I don't know more. It's a Python buildbot at:
http://www.python.org/dev/buildbot/builders/NetBSD%205%20i386%203.x/

>Description:
Python test suite (test_math and test_cmath) fails on a test of the tanh() 
result sign for float and complex numbers. Python configure script has a test 
to check if tanh() preserves the sign or not: I just commited a patch to skip 
these tests if tanh() doesn't preserve the sign.

Python (closed) bug: http://bugs.python.org/issue10337
Commit: http://svn.python.org/view?rev=86299&view=rev

Extract of Python configure test:

# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
# -0. on some architectures.
AC_MSG_CHECKING(whether tanh preserves the sign of zero)
AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <math.h>
#include <stdlib.h>
int main() {
    /* return 0 if either negative zeros don't exist
       on this platform or if negative zeros exist
       and tanh(-0.) == -0. */
  if (atan2(0., -1.) == atan2(-0., -1.) ||
      atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
  else exit(1);
}
]])],
[ac_cv_tanh_preserves_zero_sign=yes],
[ac_cv_tanh_preserves_zero_sign=no],
[ac_cv_tanh_preserves_zero_sign=no])])
AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
if test "$ac_cv_tanh_preserves_zero_sign" = yes
then
  AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
  [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
fi

So it looks like FreeBSD 6.2 has the same bug.
>How-To-Repeat:
Expected output:

$ python -c "import math; print(math.tanh(-0.0))"
-0.0
>Fix:



Home | Main Index | Thread Index | Old Index