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

add support for mpfr_get_z_2exp #80

Open
programmerjake opened this issue Jul 14, 2019 · 4 comments
Open

add support for mpfr_get_z_2exp #80

programmerjake opened this issue Jul 14, 2019 · 4 comments

Comments

@programmerjake
Copy link

We (libre-riscv.org) are thinking of using bigfloat to test a hardware floating-point implementation. It would be useful to be able to extract the exact value as a python2 long/python3 int since that's probably much more efficient than using conversion to/from string for each conversion.

@mdickinson mdickinson added this to the 0.4 milestone Dec 29, 2019
@mdickinson
Copy link
Owner

Apologies for the (very) late response; you've probably already figured out that this library doesn't get as frequently maintained as it should, and moved on.

But in case you haven't: mpfr_get_z_2exp wouldn't be all that easy to implement in this library, since we'd need to add support for the GMP integer type, and then conversions to and from that type to Python's bigint type; currently, bigfloat doesn't know anything about GMP mpz objects.

Have you looked at gmpy2? That probably does everything you need.

@mdickinson mdickinson removed this from the 0.4 milestone Dec 30, 2019
@programmerjake
Copy link
Author

Apologies for the (very) late response; you've probably already figured out that this library doesn't get as frequently maintained as it should, and moved on.

No problem, I ended up writing my own implementation of IEEE 754.

But in case you haven't: mpfr_get_z_2exp wouldn't be all that easy to implement in this library, since we'd need to add support for the GMP integer type, and then conversions to and from that type to Python's bigint type; currently, bigfloat doesn't know anything about GMP mpz objects.

Ok.

@mdickinson
Copy link
Owner

Not closing this issue, because it would make sense to have analogues of the various get and set methods that work with Python long integers; but it's unlikely that the most convenient / efficient way to implement those would be through the existing get_z / set_z functions.

I'd also need to figure out the right names to use; if we have a function mpfr_get_z_2exp that returns a Python integer (and exponent), that would preclude adding a genuine wrapper for mpfr_get_z_2exp at a later date. So we need something other than "z" to represent a Python integer. mpfr_get_pi_2exp? mpfr_get_y_2exp?

@programmerjake
Copy link
Author

maybe mpfr_get_pyint_2exp?

mpfr_get_pi_2exp seems confusing due to confusing pi with the mathematical constant π.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants