Re: [xml] XPath mod operator problems
- From: Justin Fletcher <justin fletcher ntlworld com>
- To: xml gnome org
- Subject: Re: [xml] XPath mod operator problems
- Date: Thu, 27 Jun 2002 22:45:00 +0100
In message <15643 13793 243565 537255 guitars rock roll>
Geert Kloosterman <geertk ai rug nl> wrote:
Hi Daniel, all,
When I change the following lines of xpath.c (l. 4890, 4891),
ctxt->value->floatval = arg2 * (tmp - (double)((int)tmp));
ctxt->value->floatval = fmod(arg1, arg2);
the behaviour looks correct. But I don't know if fmod conforms
to the XPath requirements of the `mod' operator.
I don't think anyone has replied with the standards on these; I only have C
ISO/IEC 9899:1999 to hand, but the relevant section is 184.108.40.206 and
2 The fmod functions compute the floating-point remainder of x/y.
3 The fmod functions return the value x - ny, for some integer n such
that, if y is nonzero, the result has the same sign as x and magnitude
less than the magnitude of y. If y is zero, whether a domain error
occurs or the fmod functions return zero is implementation-defined.
XPath 1.0 states :
The mod operator returns the remainder from a truncating division. For
* '5 mod 2' returns '1'
* '5 mod -2' returns '1'
* '-5 mod 2' returns '-1'
* '-5 mod -2' returns '-1'
Note: 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.
This would appear to me to be compatible, and thus suitable for use.
I haven't got earlier versions of the spec but I believe that the
fmod function has been part of the standard library for some time.
... Eyes to the heavens, screaming at the sky;
Trying to send you messages, but choking on goodbye.
] [Thread Prev