<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>28679</bug_id>
          
          <creation_ts>2015-05-22 20:34:15 +0000</creation_ts>
          <short_desc>math:log contradiction about result when argument is zero</short_desc>
          <delta_ts>2016-12-16 19:55:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 3.1</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Priscilla Walmsley">pwalmsley</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>120421</commentid>
    <comment_count>0</comment_count>
    <who name="Priscilla Walmsley">pwalmsley</who>
    <bug_when>2015-05-22 20:34:15 +0000</bug_when>
    <thetext>The text describing math:log says &quot;The effect is that if the argument is less than or equal to zero, the result is NaN.&quot;  But, the 2nd example says that if the argument is zero, the result is -INF rather than NaN.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120593</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-05-29 08:27:23 +0000</bug_when>
    <thetext>The same problem applies to math:log10(0)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120594</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-05-29 08:58:09 +0000</bug_when>
    <thetext>Thanks for raising this.

IEEE 754-2008 says (section 9.2.1) that log(0) and log10(0) return -INF and signal the divideByZero exception.

We say in section 4.2:

The [IEEE 754-2008] specification also describes handling of two exception conditions called divideByZero and invalidOperation. The IEEE divideByZero exception is raised not only by a direct attempt to divide by zero, but also by operations such as log(0). The IEEE invalidOperation exception is raised by attempts to call a function with an argument that is outside the function&apos;s domain (for example, sqrt(-1) or log(-1). These IEEE exceptions do not cause a dynamic error at the application level; rather they result in the relevant function or operator returning NaN. The underlying IEEE exception may be notified to the application or to the user by some ·implementation-defined· warning condition, but the observable effect on an application using the functions and operators defined in this specification is simply to return NaN with no error.

Both Java and .NET follow our examples: log(0) returns -INF, while log(-1) returns NaN.

The text in 4.2 also appears to be incorrect as regards simple division by zero. Like log(0), division by zero returns ±INF, and signals the divideByZero exception.

I suggest revising the relevant paragraph in 4.2 to read:

The [IEEE 754-2008] specification also describes handling of two exception conditions called divideByZero and invalidOperation. The IEEE divideByZero exception is raised not only by a direct attempt to divide by zero, but also by operations such as log(0). The IEEE invalidOperation exception is raised by attempts to call a function with an argument that is outside the function&apos;s domain (for example, sqrt(-1) or log(-1)&lt;add&gt;)&lt;/add&gt;. &lt;add&gt;Although IEEE defines these as exceptions, it also defines &quot;default non-stop exception handling&quot; in which the operation returns a defined result, typically positive or negative infinity, or NaN. With this function library,&lt;/add&gt; these IEEE exceptions do not cause a dynamic error at the application level; rather they result in the relevant function or operator returning &lt;mod&gt;the defined non-error result&lt;/mod&gt;. The underlying IEEE exception may be notified to the application or to the user by some ·implementation-defined· warning condition, but the observable effect on an application using the functions and operators defined in this specification is simply to return &lt;mod&gt;the defined result (typically -INF, +INF, or NaN)&lt;/mod&gt; with no error.

Then in math:log and math:log10 we should say &quot;The effect is that if the argument is zero, the result is -INF, and if the argument is less than zero, the result is NaN.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120667</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-06-02 20:29:18 +0000</bug_when>
    <thetext>The proposal was accepted and has been applied.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>