Big-Float constants `ee` and `pi` don't change to match precision.
Izaakwltn opened this issue · comments
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.
note: this is only an issue with the MPFR version of the library. The portable version handles this fine.
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
andExponentiable Big-Float
, which will automatically update the definition ofpi
andee
respectively. This could be kept in separate functions likereset-bf-constants
orset-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
toMPFR-Float
and make a newBig-Float
type in the style ofimpl-default.lisp
that usesMPFR-Float
s instead ofDyadic
s. This is probably the nuclear option. -
Simplifying the possibility above, give
Big-Float
two constructors that contain either anMPFR-Float
object or a(Unit -> MPFR-Float)
function:
(define-type Big-Float
(BFValue MPFR-Float)
(BFConst (Unit -> MPFR-Float))
Ignoring potential language changes, the last suggestion would be the right approach.