flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
456 stars 137 forks source link

arb_get_str: correct output? #399

Open Chris00 opened 2 years ago

Chris00 commented 2 years ago

Thanks for your library. The following code (attached):

int main() {
  slong prec = 52;
  arb_t x, pi;
  char *s;

  arb_init(x);  arb_init(pi);
  arb_const_pi(pi, prec);
  arb_zero(x);
  arb_union(x, x, pi, prec);
  arb_printd(x, 16);
  printf("\n");

  s = arb_get_str(x, 16, ARB_STR_MORE);
  printf("OK: %s\n", s);
  s = arb_get_str(x, 16, 0);
  printf("??: %s\n", s);

  return 0;
}

prints

1.570796326794897 +/- 1.5708
OK: [1.570796326794897 +/- 1.58]
??: [+/- 3.15]

I'm surprised by the last output. Doesn't 0 denotes the absence of flags?

test_arb.c.zip

fredrik-johansson commented 2 years ago

Yes, 0 denotes the absence of flags. The behavior is intended: by default, arb_get_str only returns digits of the midpoint known to be correct (up to +/- 1 in the last place). Here, no digits are known to be correct since the interval includes points near 0, 1, 2 and 3.