[bug] FloatQ pi is not the extended precision nearest pi

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug] FloatQ pi is not the extended precision nearest pi

Nicolas Cellier-3
Issue status update for
http://smalltalk.gnu.org/node/312
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/312

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  nice
 Updated by:   nice
 Status:       active

I get a surprising result:

> FloatD pi sin abs < FloatQ pi sin abs.
true

Let pi be an exact representation.
I expect (pi - FloatD pi) abs > (pi - FloatQ pi) abs
And thus same relation-ship between sin...

I suspect FloatQ pi is not the nearest to pi:
> (FloatQ class>>#pi) methodSourceString
'pi [
       "Returns the value of pi. Hope is that it is precise enough"

       
       ^3.1415926535897930885169542232694q
   ]'

In contrast, the first decimals I compute are:
3.1415926535897932384626433832795028841971693993751058209749445923078164062862
3.1415926535897930885169542232694q
3.141592653589793d
3.1415928e

And this one is consistent with what I compute:
> -1.0q arcCos
3.1415926535897932385

So I presume this is worth a bug report




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] FloatQ pi is not the extended precision nearest pi

Paolo Bonzini-3
Issue status update for
http://smalltalk.gnu.org/project/issue/312
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/312

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  nice
 Updated by:   bonzinip
-Status:       active
+Status:       fixed

I fixed this by using base-16 constants.

Note that while comparing /FloatX pi abs/ works for sine, it does not
necessarily work where the derivative is not close to 1.  For example
an approximation /L'/ to /ln 10/ from the right may be better than a
second approximation /L''/ from the left, and yet /|eL'-10|/ can be
greater than /|eL''-10|/.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk