Re: pi seems not to be a constant

[email protected] (Don Cohen)
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
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?
I think that "wrong" means different from intended.

 (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.


 > 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.
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. 

BTW, it now occurs to be that things like MOST-POSITIVE-LONG-FLOAT
have to be reinterpreted compared to other lisp implementations:
(setf (EXT:LONG-FLOAT-DIGITS) 128) 
(setf mp128 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.

------------------------------------------------------------------------------
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.