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,
[snip]
When I change the following lines of xpath.c (l. 4890, 4891),
xmlXPathModValues:
tmp=arg1/arg2;
ctxt->value->floatval = arg2 * (tmp - (double)((int)tmp));
into
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 7.12.10.2 and
7.12.10.3 :
--8<--------
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.
--8<--------
XPath 1.0 states :
--8<--------
The mod operator returns the remainder from a truncating division. For
example,
* '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.
--8<--------
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.
--
Gerph {djf0-.3w6e2w2.226,6q6w2q2,2.3,2m4}
URL: http://www.movspclr.co.uk/
... Eyes to the heavens, screaming at the sky;
Trying to send you messages, but choking on goodbye.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]