|
From: Raymond T. <toy...@gm...> - 2025-12-05 23:50:19
|
On 12/5/25 3:41 PM, Richard Fateman wrote: > (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. The bigfloat package is intended to hide these implementation details while still using the original algorithms from float.lisp so that there are no weird and very hard to debug regressions in bfloat arithmetic. It won't be as fast as using the bare code from float.lisp, but hopefully it's a lot less error-prone and easier to write and debug. If someone really, really needs that speed boost, they can still get down and dirty with the original code. |