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 301162 - round, ceil and floor does not work correctly with large numbers
round, ceil and floor does not work correctly with large numbers
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.19
Other All
: Normal enhancement
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-04-19 08:24 UTC by Veniamin Goldin
Modified: 2017-06-08 11:14 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Veniamin Goldin 2005-04-19 08:24:20 UTC
Please describe the problem:
When trying to apply round, ceil or floor to the number like 2353231086, the
result is -1941736209

Steps to reproduce:
1. <xsl:value-of select="round(2353231086)"/>

Actual results:
The result is wrong

Expected results:
Nothing should be done for the number like that

Does this happen every time?
Yes

Other information:
Maybe, the problem is in the xmlXPathFloorFunction, xmlXPathCeilingFunction and
xmlXPathRoundFunction functions where the actual value ctxt->value->floatval is
being casted to the int (4 bytes) and then back to the double (8 bytes) (f =
(double)((int) ctxt->value->floatval)) when the initial value is double (8 bytes).
Comment 1 William M. Brack 2005-04-19 14:40:31 UTC
Your analysis is completely correct.  I have put some code into xpath.c which
avoids the problem, but I'm not sure it's the "best" solution so I'm going to
leave the bug open until I can discuss it further with Daniel.  Since there is a
fix, I'm changing the severity to 'enhancement' until we decide whether there's
a better way.  Fixed code is in CVS - thanks for the report and for the work you
did in tracing the problem!

Bill
Comment 2 Nick Wellnhofer 2017-06-08 11:14:38 UTC
This was fixed long ago and improved with the following commit:

https://git.gnome.org/browse/libxml2/commit/?id=4bebb030db2100fce5b43fbbae413d372ee70497