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

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

____________________________________________

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