[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters ]

## SANE: Eiffel Numerical Environment |

Written by Alex Cozzi.

- Targets SmallEiffel -0.79 on a SUN Solaris 2.6 workstation.
- 25 September 1998.
- Eiffel Forum Freeware License.

sane.tar.gz (4,441 bytes) - source
code

http://www.neurop2.ruhr-uni-bochum.de/~cozzi/eiffel/sane.html
(SANE home page)

http://www.neurop2.ruhr-uni-bochum.de/personal/cozzi/home.html
(Alex Cozzi's home page)

This is a small set of classes to handle some obscure aspects of IEEE arithmetic in Eiffel. It is the embryo of a set of numerical classes for Eiffel. See http://www.neurop2.ruhr-uni-bochum.de/~cozzi/eiffel/sane.html for more infomations.

The first class handles the classification of IEEE Floating Point numbers, classifying zeros, NaNs, infinities, normal and subnormal number.

To compile the example program do:

compile double_classfiable_test.e classify.c

and then run `a.out`

The importance of the classification functions is to be able
to handle correclty these "strange beasts" of IEEE
arithmetic. For example, the "* max*"
routine should be written so that if one of the two arguments is
a NaN, it should return the other value. But the normal
implementation does not do this. For example:

max(x, y : DOUBLE) : DOUBLEisdoifx > ythenResult := xelseResult := yendend

in the case that `x := NaN` and `y := 1.0` the
result will be `1.0`, correct, but in the case, i.e., `x
:= 1.0` and `y := NaN`, it will return the `NaN`
(every comparision on NaNs gives false), wrong!

In the ideal case * REAL* and

max(x, y : DOUBLE) : DOUBLEisdoifx > ythenResult := xelseify.is_nanthenResult := xelseResult := yend end end

which it is correct even in the face of NaNs

The second class toggles the different rounding modes specified by the IEEE 754 standard. To compile and run the example, do:

compile ieee_rounding_mode_test.e rounding.c

and then run `a.out`.

What is this useful for?

The implementation of the IEEE rounding modes control permits an easy and efficient implementation of interval arithmetic. If Eiffel could provide interval arithmetic facilities that are well integrated it would go a long way in diagnosing and preventing problems in numerical software. Interval arithmetic provides a way to estimate the roundoff errors in floating point computation. In synthesis, it is able to warn the programmer when he is using a numerically instable algorithm and to determine how many figures of the results are significative.

[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters ]