Re: pi seems not to be a constant
Pierpaolo Bernardi <[email protected]>
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <CANY8u7GLpnVz-QgRg4H5muszpBZaTjzFy03LvgoougGksrSvqA@mail.gmail.com> |
On Sun, Oct 18, 2015 at 8:57 PM, Don Cohen <[email protected]> wrote: > Pierpaolo Bernardi writes: > > On Sun, Oct 18, 2015 at 8:02 PM, Don Cohen > > <[email protected]> wrote: > > > Pierpaolo Bernardi writes: > > > > > > At the cost of every computation involving pi and long floats > > > > returning wrong answers! > > > > > > Why do you think they're wrong? > > > > They would be wrong if PI had not the required long float precision. > > Wrong in what sense? PI is required to be the best long float approximation to pi. If it wasn't then it would be wrong. Also, PI is required to be a constant variable. It isn't and so it's wrong. But i think this "wrong" is a very small price to pay in exchange for having adjustable precision long floats. > (setf (EXT:LONG-FLOAT-DIGITS) 128) > (setf s2 (sqrt 2l0)) > (setf (EXT:LONG-FLOAT-DIGITS) 64) > (* 2 s2) > Is this now wrong because s2 was computed with higher precision? > If this is what I intended then I think it's right. In this case you are using a Clisp extension and you are getting what Clisp promises to deliver. So it is right. > > PI not being a constant is a much more benign non conformity. Surely > > you can work around it? > > I think you could use ext:pi for the cases where you want it to > change. The problem then is the value of CL:PI. What do you propose it should be? > In fact, it occurs to me that it would make more sense to use > (pi &optional precision) to compute pi (values could still be cached), > and allow special binding of *ext:long-float-digits* to control > default precision. The problem of what should be the value of CL:PI remains. > BTW, it now occurs to be that things like MOST-POSITIVE-LONG-FLOAT > have to be reinterpreted compared to other lisp implementations: > (setf (EXT:MOST-POSITIVE-LONG-FLOAT) > (setf (EXT:LONG-FLOAT-DIGITS) 64) > (> mp128 MOST-POSITIVE-LONG-FLOAT) > => > T > > It would make sense to me to treat these other "constants" in the same > way I now propose to treat pi. If you use EXT:LONG-FLOAT-DIGITS then you are outside of portable CL, and you should take into account your uses of this function in your coding. If you don't use EXT:LONG-FLOAT-DIGITS then the only non-confomance is that some things that should be constant variables are variables instead (but they won't in fact vary). ------------------------------------------------------------------------------ _______________________________________________ clisp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-list