This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.

SANE: Eiffel Numerical Environment

Maintainer

Alex Cozzi

Description

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.

Categories

Versions

Links

Features

Classification

Class DOUBLE_CLASSIFIABLE 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) : DOUBLE is

    do
        if x > y then
            Result := x
        else
            Result := y
        end

    end

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 DOUBLE should inherit CLASSIFIABLE_NUMBER and the max function could then be rewritten as:

max(x, y : DOUBLE) : DOUBLE is
    do
        if x > y then

            Result := x
        else
            if y.is_nan then
                Result := x
            else 
                Result := y
            end
        end
    end

which it is correct even in the face of NaNs

Rounding

Class IEEE_ROUNDING_MODE 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 significant.

Supported compilers

Platforms

Licensing

Google
 
Web eiffelzone.com