need system error-code.

H

Holger.Rostalski

hello
i have an very old code here, wich worked long time very well.
but now i 've got a bugreport that there is a problem with "nan" for
delta_sigma.

in my code is a very long math-calculation


==============
delta_sigma = b * sinus_sigma * (cosinus_2_sigma_m + 0.25 * b *
(cosinus_sigma * (-1. + 2. *
cosinus_2_sigma_m_q) -
(1. / 6.) * b * cosinus_2_sigma_m * (-3. + 4. *
sinus_2_sigma) * (-3. + 4. *
cosinus_2_sigma_m_q)));
==============

all used variables are from the type double and are in all cases valid
but close to zero. and sinus_sigma is exact zero.

normaly the result has to be delta_sigma==0 but here it is "nan"

when i split the calculation into parts like


================================
term1=(cosinus_2_sigma_m + 0.25 * b *
(term4 - (1. / 6.) * b * cosinus_2_sigma_m
*term3 * term 2 )

term2=(-3. + 4. * cosinus_2_sigma_m_q)
term3= (-3. + 4. * sinus_2_sigma)
term4=cosinus_sigma * (-1. + 2. * cosinus_2_sigma_m_q)

delta_sigma = b * sinus_sigma * term1;
================================
now delta_sigma isnt "nan" and the result is right delta_sigma==0


i work with the gnu-compiler g++.


it looks like a problem with the accuracy of a double-value.


Now the question
============
Is it possible to get an errorcode from the system about this
calculation? Or is there an other way to solve this problem?
 
K

Keith Thompson

i have an very old code here, wich worked long time very well.
but now i 've got a bugreport that there is a problem with "nan" for
delta_sigma. [snip]
i work with the gnu-compiler g++.

g++ is a C++ compiler, not a C compiler. It's likely that your
problem would occur either in C or in C++, but we can't be sure.

Either recompile your code using "gcc" or some other C compiler, or
post to comp.lang.c++.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top