piclist 2004\11\03\215434a >
Thread: fwd: Floating Point Underflows and Overflows
www.piclist.com/techref/microchip/devices.htm?key=pic
picon face BY : Bob Ammerman email (remove spam text)



>>:: {
>>:: double t1, t2, t3;
>>::
>>:: t1 = 1.5E-20;
>>:: t2 = 1.4E-20;
>>:: t3 = t1 * t2;
>>:: }
>>::

The result you have is too large by a factor of exactly 2 raised to the
256th power. Isn't that interesting?

What is happening is that your floating point package is adding the
exponents of the binary form of the floating point numbers, and ignore
overflow.

If you have access to the source of the floating point routines you could
put in an appropriate overflow check (although I am not sure what you should
do if you encounter overflow).


Alternatively, you could extract the exponents from the values and determine
a reasonable range for the expected exponent of the result. Then check that
the exponent of the result is in that range.

Bob Ammerman
RAm Systems

____________________________________________
<001301c4c219$92ef3e20$6400a8c0@dell8100> 7bit

See also: www.piclist.com/techref/microchip/devices.htm?key=pic

Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) fwd: Floating Point Underflows and Overflows

month overview.

new search...