Floating point exceptions

Michael S. Klein mklein at alumni.caltech.edu
Mon Mar 22 22:06:14 UTC 1999


> <fifty-percent-joke>
> I think the obvious thing to do is to get rid of Floats.  They cause more
> trouble than they're worth.
> </fifty-percent-joke>

I think introducing the concept of exact/inexact numbers (from Scheme) is 
the right way to go. The basic idea is that operations with inexact 
parameters answer inexact results (a "contagion"). 

The upside is that if you get an exact number, you dont have to worry 
about things like round-off errors.  Think how nice it is to have Fractions
where 

	(4 / 3 * 3) = 4

(I displayed the equation above separate to avoid decimal point vs. 
period :-).  One could extend the realm of exact representations so that

	5 sqrt squared = 5

The downside is that you have to think about equality a lot harder
(thinking harder is a downside?!?!?)
about equality and Scheme deals with this by a proliferation of equality
functions.

As the Scheme spec says: 


	It is important to distinguish between the mathematical numbers, the 
	Scheme numbers that attempt to model them, the machine representations 
	used to implement the Scheme numbers, and notations used to write 
	numbers. This report uses the types number, complex, real, rational, and 
	integer to refer to both mathematical numbers and Scheme numbers. Machine 
	representations such as fixed point and floating point are referred to by 
	names such as fixnum and flonum. 



-- Mike Klein





More information about the Squeak-dev mailing list