https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78415
Bug ID: 78415 Summary: sqrtq does not round correctly when round mode is upward Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libquadmath Assignee: unassigned at gcc dot gnu.org Reporter: walter.mascarenhas at gmail dot com Target Milestone: --- // // The code below shows that sqrtq does not round // correctly when the rounding mode is upwards. // #include <cassert> #include <cmath> #include <quadmath.h> #include <cfenv> int main() { __float128 x = 1.0; x += 2.0 * FLT128_EPSILON; std::fesetround(FE_UPWARD); __float128 su = sqrtq(x); // the sqrt is rounded to 1 + 2 epsilon, whereas the least __float128 // above the mathematical sqrt(1 + 2 epsilon) is 1 + epsilon: // The Taylor series for sqrt around 1 yields // sqrt(1 + 2 epsilon) ~ 1 + epsilon - epsilon^2/2 < 1 + epsilon. assert(su == x); }