[Mpc-discuss] Inaccurate mpc_atan results

Joseph Myers joseph at codesourcery.com
Tue Mar 7 19:15:45 CET 2017

I'm seeing inaccurate results from mpc_atan (in MPC 1.0.3), resulting in 
bad expectations being generated for glibc tests and test failures as 
reported at <https://sourceware.org/ml/libc-alpha/2017-03/msg00095.html>.

Consider the following test, which computes atan (0 + 0x1.000002p+0 i), 
rounded towards 0 to 115 bits, in two different ways (directly, or 
rounding to zero to 500 bits then rounding that to 115 bits).

#include <stdio.h>
#include <mpc.h>
#include <mpfr.h>

main (void)
  mpc_t a, b, c;

  mpc_init2 (a, 115);
  mpc_init2 (b, 500);
  mpc_init2 (c, 115);
  mpc_set_str (a, "(0 0x1.000002p+0)", 0, MPC_RNDZZ);

  mpc_atan (b, a, MPC_RNDZZ);
  mpc_set (c, b, MPC_RNDZZ);
  mpfr_printf ("%Ra\n", mpc_imagref (c));
  mpc_atan (c, a, MPC_RNDZZ);
  mpfr_printf ("%Ra\n", mpc_imagref (c));
  putc ('\n', stdout);

  return 0;

This outputs:


(ending a0e and e0e respectively).  The two results should of course be 

Joseph S. Myers
joseph at codesourcery.com

More information about the Mpc-discuss mailing list