After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783238 - Parsing XPath numbers is inaccurate
Parsing XPath numbers is inaccurate
Status: RESOLVED DUPLICATE of bug 629325
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Nick Wellnhofer
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2017-05-30 12:03 UTC by Nick Wellnhofer
Modified: 2017-06-08 12:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Nick Wellnhofer 2017-05-30 12:03:16 UTC
Parsing XPath Number literals or converting strings to numbers during evaluation is currently done with a naive algorithm that can produce lots of floating-point rounding errors. It would be better to simply verify the Number syntax and use strtod or atof to do the conversion. The library routines typically guarantee to return the nearest floating-point number.

But there are some challenges. strtod depends on the locale, so we should probe for strtod_l and use it if available. Also, newer glibc versions make strtod respect the current rounding mode (see C99's fesetround). C11 clarifies that the floating point environment is maintained separately for each thread, but I'm not sure whether setting and restoring the rounding mode is thread-safe on all platforms.
Comment 1 Nick Wellnhofer 2017-06-08 12:03:14 UTC

*** This bug has been marked as a duplicate of bug 629325 ***