Hi

working with CW 6.1 and a MC13213 i ran into problems with the floatingLib.

I constructed a snippet that brings up the kind of problem. (even in the true-time-simulation)

I calculate x3 = (2.5e-11) - (1.7e-20)*(1.7e-20).

and would expect one of the following:

2.5e-11 (plus minus some rounding error), or NaN, or +Inf , or -Inf.

But I get: x3==-3.34...e+37

And this is not conform to IEEE 754 as far as i can see.

I already tried using a Service Request, but it got closed.

And i have no solution to the problem yet.

Q1: are you able to reproduce the behavior?

Q2: can you understand, why i expect a different result?

Q3: is this conform to IEEE in your opinion?

Q4: do you know a solution?

Aswers to any of these Questions is welcome.

many thanks

Fabian

int main(){

volatile float x1;

volatile float x2a;

volatile float x2;

volatile float x3;

x1=2.5e-11; /** this is within normalized range **/

x2a=1.7e-20; /** this is within normalized range **/

x2 = x2a*x2a; /** this is within denormalized IEEE754

range **/

x3=x1-x2; /** this goes wrong i think **/

SOPT_COPE=0;

while( x3<0 ); /** this halts, but should not **/

for(;; /** this should halt but is never reached **/

}

2.5e-11 is the right answer. NaN and Inf would be wrong.

With CW6.3 I got -2.889996e-040 (- (1.7e-20) ^2 ) , which is also wrong.

Of course.

not good

Yes. Different answer but also wrong.

Of course yes.

No

It can be solved this way 1) testing existing FP routines implementation for IEEE conformance. Everything can be found here: http://www.math.utah.edu/~beebe/software/ieee/

2a) Using slow but already tested SoftFloat http://www.jhauser.us/arithmetic/SoftFloat.html

2b) rolling your own FP emulation routines and testing them at least with W.M.Kahan's Paranoia.c