On Feb 15, 12:33 am, "Shhnwz.a" <mshahnawaz...@gmail.comwrote:
Hi,
I have a problem regarding handling floating point error, specially
Denormalisation error. I want to know is there any trick or technique
to find bit length of the resultant before using and floating point
operation.
e.g
before using
pow(0.5,100000);
I can precisely detect that this operation will give DE error.
That should result in a complete loss of precision (some compilers
will have TLOSS as an exception mask for instance) and not
denormalization (which is only partial loss of precision).
You could (of course) use mathematics and reason things out using
first principles. I think that the following approach is much
simpler: If your compiler allows it, you could simply turn floating
point exceptions on and add underflow and/or denormalization to the
mask of opertations to trap. I guess that the work to detect the
problems before they happen is far more expensive than the actual
operations themselves.
Another possibility is to use an arbitrary precision floating point
library and check the ranges of the values before converting them to
double or whatever your intended target precision is.
What is the actual problem that you are trying to solve?