Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!hookup!swrinde!cs.utexas.edu!utnut!nott!cunews!tina.mrco.carleton.ca!knight
From: knight@mrco.carleton.ca (Alan Knight)
Subject: Re: Substraction Problems :-(
Message-ID: <knight.794464308@tina.mrco.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Reply-To: knight@mrco.carleton.ca (Alan Knight)
Organization: Carleton University
References: <3ivu79$hsc@panix3.panix.com> <3j5kh2$a6f@news1.delphi.com> <3j7iog$l6h@crchh327.bnr.ca> <denatale-0303951906050001@grail918.nando.net> <ethridge-0403952236100001@192.0.2.1>
Date: Mon, 6 Mar 1995 04:31:48 GMT
Lines: 47

In <ethridge-0403952236100001@192.0.2.1> ethridge@netcom.com (Allen Ethridge) writes:

>It's not that i think the size
>of floats should be unrestricted so much as having the rules of numerical
>analysis applied by the computer (hardware or software).  If i remember my
>numerical analysis (from years ago) correctly, in the calculation of
>100.9 - 100.0 there can be no more than one significant digit to the right
>of the decimal point.  Why then would a computer produce a result that
>implied five significant digits - 0.90002.  It seems that this would force
>anyone writing programs with floating point numbers to right extra code
>to check all the intermediate results for the correct number of significant
>digits.  Why can't this be done automatically by the language/system/hardware?

This can. It would be relatively easy (just a small matter of
programming) to write a class of numbers which included margins of
error and propogated them in calculations. Since this is Smalltalk,
they could be fully integrated with the numeric system. This would be
quite an interesting thing to do.

This is not done with the default floating point arithmetic
operations, for several reasons.
a) nobody thought of it. They just used the CPU's floats.
b) it's potentially ambiguous. There might be more than one set of rules
c) it would slow things down a *lot*
d) people would complain

To elaborate on d), if you actually followed rules for propogating
errors you rapidly lose significant digits, something people would
probably complain about. Consider the following imaginary post

   There is a serious bug in my Smalltalk. The expression 1.10 + 1.10
   gives 2 as a result (not actually the integer 2, but 0.2e1)

This is because 1.10 really means (exactly)1.05 < x < (exactly)1.15.
The minimum and maximum result of adding x to itself are (2.1 +
infinitesimal) and (2.3 - infinitesimal). There's only one signifcant
digit left.

Numerical analysis is a large and complex field. Doing numerical
calculations with inexact representations and having stable and
accurate results is a lot harder than most people realize.

-- 
 Alan Knight                | The Object People
 knight@acm.org             | Smalltalk and OO Training and Consulting
 alan_knight@mindlink.bc.ca | 509-885 Meadowlands Dr.
 +1 613 225 8812            | Ottawa, Canada, K2C 3N2
