This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Dear cygwin team, the following c++ program (see below) is affected by a strange bug: floating point precision is decreased by uncommenting the call to gethostname(). Behaviour: * you get high precision if you do not call gethostname() * you get different values if the call is uncommented, i.e. executed * if you change the long doubles to normal doubles, values seem to be not affected by the gethostname call * the resulting values for double precision are equal to the values obtained with long doubles in case the gethostname() function is invoked This seems to happen on AMD Athlons and Opterons. I do not have an Intel system to test this behaviour on. Only OS tested was Windows XP SP1. Thank you! --> the program: #include <iostream> #include <unistd.h> int main () { char name[100]; // gethostname(name, 99); // UNCOMMENT THIS TO CHANGE BEHAVIOR const unsigned int n = 2; const unsigned int m = (n+1)/2; const long double tolerance = 5e-16; long double z = std::cos(3.1415 * (.75)/(n+.5)); long double pp; long double p1, p2, p3; do { p1 = 1.; p2 = 0.; for (unsigned int j=0;j<n;++j) { p3 = p2; p2 = p1; p1 = ((2.*j+1.)*z*p2-j*p3)/(j+1.); std::cout << p1 << " " << p2 << " " << p3 << " " << z << " " << j << std::endl; } pp = n*(z*p1-p2)/(z*z-1); z = z-p1/pp; std::cout << p1 << " " << p2 << " " << p3 << " " << " ### " << pp << " " << z << std::endl; } while (abs(p1/pp) > tolerance ); }
Attachment:
cygcheck.out
Description: Text document
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |