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?: Page 1 of 6 (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