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?
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?