Re: [xml] XPath fix

Daniel wrote:
As a heads up, I'm working on a fix for one of the number expressions -
libxml returns 1 for the expression "5.46 mod 2.6". Apparently, according
the xsl-list, it should return "0.26" (Something to do with Java doing
floating point mods, C only doing integer mods).

 Section 3.5 of the XPath spec states:
   "This is the same as the % operator in Java and ECMAScript."
   "This is not the same as the IEEE 754 remainder operation,
    which returns the remainder from a rounding division."

So they may be right, I hate those parts where XPath/XSLT relies on Java
for the semantic of operations, it is usually a mess.

That bit confused the heck out of me - so does that imply that Java doesn't
do IEEE 754 floating point numbers properly?

I've found another couple of problems with float, round and ceil.
floor(-5.2) returns -5 instead of -6
ceiling(-5.2) returns -4 instead of -5
round(-5.6) returns -5 instead of -6
I've had a look at the code in xpath.c that does this maths
(xmlXPathFloorFunction(), etc) and what I thought would have been the
correct fix (by using the real C functions) in all 3 cases has been "#if
0"'d out and replaced by approximations doing wierd things with casts.
This is probably a silly question, but was there a specific issue caused by
using the C functions that stopped them from working?


Do You Yahoo!?
Get your free address at

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]