By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Floating Point Exception

P: n/a
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.

Thanks in advance.

shhnwz.a

Feb 15 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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?

Feb 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.