W3C home > Mailing lists > Public > public-qt-comments@w3.org > August 2006

[Bug 3615] [F&O] Precision in fn:avg()

From: <bugzilla@wiggum.w3.org>
Date: Tue, 22 Aug 2006 17:41:55 +0000
To: public-qt-comments@w3.org
Message-Id: <E1GFaGB-0002SN-ED@wiggum.w3.org>


           Summary: [F&O] Precision in fn:avg()
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Functions and Operators
        AssignedTo: ashok.malhotra@oracle.com
        ReportedBy: jsnelson@sleepycat.com
         QAContact: public-qt-comments@w3.org

The specification for fn:avg() includes the line:

    Otherwise, returns the average of the values computed as sum($arg) div

Whilst this is a useful description of the results required from the function,
it could also be seen as being perscriptive of how the function must be
implemented. One consequence of this can be seen in the XQTS test
fn-avgflt2args-1, with a discussion about it in bug #3610.

To summerise, the test query is:


and the test expects a result of "-INF", since "-3.4028235E38" is the lower
bound for an xs:float and the fn:sum() operation will underflow. However, I
think it is entirely reasonable to implement fn:avg() in such a way as to
return the answer "-3.4028235E38" for this query, which is both a valid
xs:float and the correct mathematical result.

I propose that the sentance above from the F&O specification be changed to the

    Otherwise returns the average of the values, computed as sum($arg) div
    count($arg) or otherwise.
Received on Tuesday, 22 August 2006 17:42:02 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:13 UTC