W3C home > Mailing lists > Public > public-qt-comments@w3.org > June 2015

[Bug 28795] [F+O] 3.1 Non-transitive equality for numerics in maps

From: <bugzilla@jessica.w3.org>
Date: Sat, 13 Jun 2015 19:37:01 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-28795-523-ADzXcVOUiQ@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28795

--- Comment #2 from Michael Kay <mike@saxonica.com> ---
Here's a suggested definition of the same-key relation:

The same-key relation is defined as follows. Two atomic values A and B are the
same key if the expression (A eq B) is true, with the following exceptions and
caveats:

* If evaluation of the expression (A eq B) fails with a dynamic error or type
error, then A and B are not the same key.

* If A and B are both instances of one of the types xs:string,
xs:untypedAtomic, or xs:anyURI, then they are the same key if
codepoint-compare(A, B) eq 0.

* If A and B are both instances of one of the types xs:dateTime, xs:date,
xs:time, xs:gYear, xs:gYearMonth, xs:gMonth, xs:bMonthDay, or xs:gDay, then:

  ** if they are instances of different primitive types, then they are not the
same key
  ** if one of the values has a timezone and the other does not, then they are
not the same key
  ** if both have a timezone, they are the same key if and only if (A eq B)
  ** if neither has a timezone, they are the same key if and only if (A eq B)
NOTE: although the rules for comparison in this case make reference to the
implicit timezone in the dynamic context, the result is the same regardless of
the implicit timezone.

* If A and B are both instances of one of the types xs:float, xs:double, or
xs:decimal (which includes xs:integer), then [subject to bug 28795]:

  ** If A is the xs:double or xs:float value NaN, and B  is the xs:double or
xs:float value NaN, then A and B are equal.  
  ** Positive infinity equals positive infinity, and negative infinity equals
negative infinity.
  ** Except for NaN and positive or negative infinity, the two values A and B
are equal if and only if they represent the same mathematical quantity.
Effectively both A and B are converted to instances of xs:decimal using an
implementation of xs:decimal whose value space provides sufficient precision
and scale to contain the value space of xs:double (and therefore xs:float)
precisely; the values are then compared within this value space. 
  **  It follows that positive and negative zero are equal.

NOTE:
These rules are chosen (and differ from the rules for the comparison operator
“eq”) to achieve three aims:
** Comparing two atomic values never raises an error
** Equality is commutative and transitive
** Equality comparison is context-free (the result does not depend on anything
in the static or dynamic context)

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Saturday, 13 June 2015 19:37:04 UTC

This archive was generated by hypermail 2.3.1 : Saturday, 13 June 2015 19:37:04 UTC