GNOME Bugzilla – Bug 783238
Parsing XPath numbers is inaccurate
Last modified: 2017-06-08 12:03:14 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.
*** This bug has been marked as a duplicate of bug 629325 ***