|
From: Richard F. <fa...@gm...> - 2025-12-05 23:42:03
|
(fppi) returns the insides of bigfloat %pi to the current bigfloat precision. If you want the whole number with the precision encoded, then use bcons. :lisp (setf $mypi (bcons (fppi))) sets the maxima variable mypi to a bigfloat pi which in the default precision prints as 3.141592653589793b0 The lisp programs (of which there are lots of examples) generally do calculations on the "insides" with the precision understood, and presumed (required) to be the same for all bigfloat insides in the calculation. One could relax that understanding and instead insist that each number has the header, so instead of just (say) adding two bigfloats insides by (fpplus a b), we could convert a to current precision, b to current precision, add them producing a result (with header) specifying the current precision. This is what bfloat(a+b) does. (fppi) returns the lisp list (56593902016227522 2) $mypi in lisp is ((bigfloat simp 56) 56593902016227522 2) I hope this helps if someone decides to read/extend/improve/replace this code. RJF On Fri, Dec 5, 2025 at 1:49 PM Raymond Toy <toy...@gm...> wrote: > > On 12/5/25 10:41 AM, Robert Dodier wrote: > > On Fri, Dec 5, 2025 at 4:58 AM Barton Willis via Maxima-discuss<max...@li...> <max...@li...> wrote: > > Another thing: Although bfhalf automatically updates when fpprec changes, some special variables defined in globals.lisp do not. > > I wonder if any specific bigfloat values should be functions instead > of constants, so that changing fpprec causes a different value to be > returned. Or maybe baking the prevailing fpprec into the symbol name, > something like BIGFLOAT-%PI-FOR-DEFAULT-FPPREC or whatever. > > I agree on adding functions. We already have `fppi` that returns a > bigfloat pi for the current fpprec. But `fppi` returns a bfloat object sans > bfloat marker. And `fppi` is memoized. I think if you use the bigfloat > package, you get `(bigfloat:%pi num)` where `num` is only used to figure > out what kind of result to return (single, double, big float). Similarly > for `bigfloat:%e`. > > Speaking strictly for myself, I can't keep it straight in my head when > some constant is no longer valid in some context ... if developers are > supposed to "just know", then it's likely that I'll mess it up at some > point. YMMV as always. > > I don't think it's just you. > > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |