[clean-list] Re: 1.Floating Point Support (clean-list digest)

Richard A. O'Keefe ok@atlas.otago.ac.nz
Fri, 17 Nov 2000 10:27:04 +1300 (NZDT)


(Someone else asked about)
	>     Most hardware conforms, more or less well, to the IEEE 754 floating
	> point standard;  most programming languages don't support standard features
	> (precisions, rounding modes, exceptions) adequately;  Clean doesn't
	> either.
	
Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at> wrote:
	I do not know what you really mean, but rounding errors are inavoidable (in
	everey language); that is my naive assumption.
	
That's not what he was talking about.

The IEEE 754 standard, and the IEC (554?) one that has superceded it,
defines four rounding modes.  Each operation is to act as if it first
computed the result to infinite precision and then

 - truncated towards zero, O
 - rounded down towards minus infinity, OR
 - rounded up towards positive infinity, OR
 - rounded to the nearest representable number, breaking ties in favour
   of the one that ends with a 0 bit.

The last one is the normal default, but the directed rounding modes are
*extremely* handy for implementing interval or triplex arithmetic, so that
you get some idea of just how much error there might be in your computation.

	How can a programming language active control the rounding errors? A number is
	rounded up or down.
	
It is a requirement of the relevant standards that the rounding mode be
switchable under program control.  It is also a requirement of them that
whether divide by zero, underflow, overflow, &c raise exceptions or return
Not-a-Number codes.  The C99 standard has full support for the IEC standard.
I imagine that the C99 stuff will find its way into C++ compilers.

	But hasn't Clean incorporated the BigNumerical-Library for that issues?
	
With IEEE directed rounding, we are talking about controlling the *hardware*
in a way that the IEEE standard requires.