Infinity?
squeak-dev at lists.squeakfoundation.org
squeak-dev at lists.squeakfoundation.org
Thu Oct 10 03:30:38 UTC 2002
John M McIntosh <johnmci at smalltalkconsulting.com> wrote:
| Take a look on the web for 'double dispatch' and smalltalk and
remember
| it's object (message send +) object
| which leads to all sorts of interesting decisions (at a cost) you can
| do for the + message.
|
| Mmm I wonder if someone has a changeset that considers degree of error
| in calculations handy.
I once created an IntervalFloat class in Squeak which implemented a form
of interval arithmetic, which holds an upper and lower bound of the
current floating-point value. Implementation of multiplication was
something like:
| result upper lower |
lower := self lowerBound * other lowerBound.
upper := self upperBound * other upperBound.
result := self class new lowerBound: lower upperBound: upper.
^ result
Since I didn't have direct access to the FP rounding mode control, I
cheated and in instance creation made the upper bounds one ULP more than
the initial float value, and the lower bounds one ULP less.
It was interesting to see the difference between upper and lower bounds
grow quite a bit during repeated calculations, such as ray tracing.
-- tim
More information about the Squeak-dev
mailing list
|