FloatQ pi is not the extended precision nearest pi

Tagged:
Project:GNU Smalltalk
Component:Base classes
Category:bug
Priority:normal
Assigned:Unassigned
Status:fixed
Description

I get a surprising result:

st> 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:
st> (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:
st> -1.0q arcCos
3.1415926535897932385

So I presume this is worth a bug report

Updates

#1 submitted by Paolo Bonzini on Mon, 06/15/2009 - 12:45
Status:active» 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|.

User login