Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - libm error?: (6 Items)
   
libm error?  
Hi,

I believe there might be a bug in libm. "pow(x,2.0)" gives incorrect results for very small x.
The following program gives incorrect results for double pow(double,double), but correct 
results for pow(double,int). 

#include <cmath>
#include <iostream>
using namespace std;

int main(int argc,char**argv)
{
   double dz=+1e-170;
   cout<<"dz= "<<dz<<endl;
   cout<<"pow(dz,2.0)= "<<pow(dz,2.0)<<endl;
   cout<<"pow(dz,2)= "<<pow(dz,2)<<endl;
   return EXIT_SUCCESS;
}

If compiled with " QCC -o foo foo.cpp -lm"  the output is:
dz= 1e-170
pow(dz,2.0)= inf
pow(dz,2)= 0

Am I doing something wrong and if not, is there a known workaround?

Thanks,

Thomas Buschmann
Re: libm error?  
I believe this problem has already been fixed in the 6.4 libm. You can download an updated libm from the OS project at:

http://community.qnx.com/sf/frs/do/viewRelease/projects.core_os/frs.qnx_neutrino_core_os_0.6_4_m7

Regards,

Ryan Mansfield
Re: libm error?  
Thanks a lot, I'll try that!
Sincerely,
Thomas Buschmann
libm error- very serious  
Hi,

I just spent the last 3 days tracking down an issue which turned out to be this exact problem.  pow(x,2.0f) was 
returning inf.

Downloading the new libm solved this problem.  I have a few questions

1) how do I identify the version of the libm libraries to find out if this issue is lingering elsewhere.

2) which versions of the libm library have this issue.

3) does QNX not have some mechanism to notify clients when something as critical as the math library being broken is 
identified.  We are building mission critical applications and I only ran into this issue by fluke. I would have 
expected something like a RECALL being generated for something this severe.

4) do you have a list of other critical issues such as this which exist so I know what else to look out for instead of 
wasting the last 3 days like I just did.

Regards
Thom Allen
Re: libm error- very serious  
Thomas Allen wrote:
> Hi,
> 
> I just spent the last 3 days tracking down an issue which turned out to be this exact problem.  pow(x,2.0f) was 
returning inf.
> 
> Downloading the new libm solved this problem.  I have a few questions

Someone in the OS forum should be able to provide you with the 
information about which versions are affected and if there are any other 
known issues with libm.

Regards,

Ryan Mansfield
Re: libm error- very serious  
Seems to only works for me if I remove the 

libm.so, 
libm.so.2 and
libmS.a

and keep the libm.a of release 6.4.
Anybody knows why? The feeling I had was that it was actually first trying link to libm.so which is would then be still 
faulty and if not found link to the archive file (libm.a)
Does it make sense to anybody?