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

Big-Float constants ee and pi don't change to match precision. #1013

Open
Izaakwltn opened this issue Oct 11, 2023 · 3 comments
Open

Big-Float constants ee and pi don't change to match precision. #1013

Izaakwltn opened this issue Oct 11, 2023 · 3 comments
Labels
bug Something isn't working standard library

Comments

@Izaakwltn
Copy link
Collaborator

These variables are locked in with the initial big-float precision, and don't adjust as precision changes.

Initial precision is 53 bits so they're basically locked in as Double-Floats.

@Izaakwltn Izaakwltn added the bug Something isn't working label Oct 11, 2023
@stylewarning
Copy link
Member

note: this is only an issue with the MPFR version of the library. The portable version handles this fine.

@Izaakwltn
Copy link
Collaborator Author

I've been thinking about this bug, and thought of a couple quick but potentially janky approaches for fixing it.

  • Every time precision is set, redefine Trigonometric Big-Float and Exponentiable Big-Float, which will automatically update the definition of pi and ee respectively. This could be kept in separate functions like reset-bf-constants or set-precision-and-constants. Bubble-gum and paperclip approach.

    • Note: Is it possible to redefine one member of a type class or does every redefinition have to be applied as a whole?
  • Convert Big-Float to MPFR-Float and make a new Big-Float type in the style of impl-default.lisp that uses MPFR-Floats instead of Dyadics. This is probably the nuclear option.

  • Simplifying the possibility above, give Big-Float two constructors that contain either an MPFR-Float object or a (Unit -> MPFR-Float) function:

(define-type Big-Float
  (BFValue MPFR-Float)
  (BFConst (Unit -> MPFR-Float))

@stylewarning
Copy link
Member

Ignoring potential language changes, the last suggestion would be the right approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working standard library
Projects
None yet
Development

No branches or pull requests

2 participants