This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XPath floating point arithmetic
- From: Elliotte Rusty Harold <elharo at metalab dot unc dot edu>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 20 Mar 2002 12:10:24 -0500
- Subject: Re: [xsl] XPath floating point arithmetic
- References: <007001c1d02e$0aa4f3a0$4e0aa8c0@3b2.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
At 4:40 PM +0000 3/20/02, Richard Jinks wrote:
>Hi
>
>Can someone ease a bit of confusion for me, please?
>
>In relation to XPath, what would the answer be to the following operation:
>
>5.46 mod 2.6
>
>Should it be
>
>a) 1 (implying the numbers are rounded to nearest integer, then 'mod'ed)
>b) 0.26 (implying some sort of floating point mod operation)
>c) something else (implying I've got my sums wrong and need to learn how to
>use a calculator)
>
The spec says "This is the same as the % operator in Java and
ECMAScript" and in Java 5.46 mod 2.6 is indeed 0.26 (modulo rounding
error) If libxml isn't giving you that, then it's a bug.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.cafeconleche.org/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list