- From: Dave Peterson <davep@iit.edu>
- Date: Wed, 2 Jul 2008 17:25:04 -0400
- To: Alan Ruttenberg <alanruttenberg@gmail.com>, www-xml-schema-comments@w3.org
At 2:18 PM -0400 2008-07-02, Alan Ruttenberg wrote: >Was there at any point explicit rejection of have a mathematical >real number datatype (possibly augmented with some constants such as >INF, -INF) from which the rest of the numeric types were defined by >restriction? Yes. There is a potential hierarchy of complex numbers, real numbers, and rational numbers that could exist above our decimal datatype. Not many systems implement them, and conformance to our spec requires that all datatypes be implemented, at least enough to pass from one system to another. So we didn't include them. But I think what you probably want is to derive float and double from decimal. The problem with that is that such a derivation would violate a fundamental property that we wanted derivation to have: If a value is removed from the value space during a derivation, that automatically removes its lexical representations from the lexical space. However, float and double require that strings that exactly represent a decimal value not in the float or double value space be mapped to the nearest value that is in the lexical space. Rather than remove that fundamental property of derivation, we decided to leave float and double as separate primitives. Trying to define equality (for example) across, say, decimal and float, leads to its own problems: In float, 0.1 and 0.10000000009 are the same number (exactly 0.100000001490116119384765625, i believe). In decimal, they are different. (Both 0.1 and 0.10000000009 are in the value space of decimal, but neither is in the value space of float. Because we round exact values of literals whose exact value is not in the float value space, the float values 0.1 and 0.10000000009 are equal. We would expect the statement '0.1 = 0.10000000009' to be true. On the other hand, '0.1 = 0.10000000009' is false in the decimal datatype. If we allow comparison across the two datatypes, o '0.1(float) = 0.1(decimal)' presumably true, o '0.1(decimal) = 0.10000000009(decimal)' false, o '0.10000000009(decimal) = 0.10000000009(float)' presumably true But from that (a = b != c = d) we can conclude (a != d), i.e. '0.1(float) = 0.10000000009(float)' is false. I don't believe there is any way to make a meaningful equality across float and double that retains the usual rules about equality (e.g., reflexive, symmetric, transitive) and allows you to compare other than exact values. Or do you want '0.1(float) = 0.1(decimal)' to be false? (So that the only decimal value equal to 0.1(float) is 0.100000001490116119384765625)? >We have a discussion going in the OWL working group, part of which >is about the desirability of comparing a float to an integer. If >they are disjoint, then that doesn't seem possible. However, it >seems well defined to ask whether "2.1"^^xsd:float > "2"^^xsd:int Easy to pick carefully selected values that make sense. But can you give me a way to filter out the ones where it doesn't make sense (as in the equality example above)? If you go by exact values, then 2.1(float) > 2.10000000009(decimal). That doesn't seem very intuitive to me. -- Dave Peterson davep@iit.edu
Received on Wednesday, 2 July 2008 21:25:44 UTC