Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arb_get_str() & arb_set_str() does not preserve value #412

Open
saraedum opened this issue Mar 31, 2022 · 5 comments
Open

arb_get_str() & arb_set_str() does not preserve value #412

saraedum opened this issue Mar 31, 2022 · 5 comments

Comments

@saraedum
Copy link
Member

saraedum commented Mar 31, 2022

Consider the following C program.

$ cat roundtrip.c
#include <arb.h>

int main() {
  arb_t a;
  arb_init(a);

  arb_load_str(a, "2bb573849d73 -2c 800031b 365d");

  arb_printn(a, 1024, ARB_STR_MORE);

  arb_set_str(a, arb_get_str(a, 1024, ARB_STR_MORE), 1024);

  arb_printn(a, 1024, ARB_STR_MORE);
}

When run (with Arb 2.22.1 from conda-forge) it prints:

[+/- 3.65e+4197][+/- 3.66e+4197]

I understand that arb_get_str() can introduce imprecision and I also understand that I should probably use arb_dump_str to serialize an arb_t; but shouldn't arb_set_str() preserve the radius?

@albinahlback
Copy link
Contributor

Neither arb_get_str nor arb_set_str says in their documentation that they preserve the radius. It only states that the old interval is contained in the new interval.

@saraedum
Copy link
Member Author

@albinahlback Thanks, I am aware of that. I am not saying that the implementation breaks the documentation.

@albinahlback
Copy link
Contributor

Then what is your issue? You asked if arb_set_str preserves the radius, for which I gave an answer.

@saraedum
Copy link
Member Author

saraedum commented Mar 31, 2022

My question was: Shouldn't arb_set_str() try to preserve the radius here?

@saraedum
Copy link
Member Author

Note that this is somewhat related to #391. In #391 arb_get_str introduces an error, here arb_set_str introduces an error.

I wonder if both methods could be more careful when it's possible not to introduce any error.

@saraedum saraedum changed the title arb_get_str() & arb_get_str() does not preserve value arb_get_str() & arb_set_str() does not preserve value Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants