[om] OM Floats (XML Representation)

David Carlisle davidc at nag.co.uk
Thu Nov 27 12:13:30 CET 2003


Bill's recent question on the hex attribute of <OMF/>  reminded me of a
long standing issue....


OMF represents an IEEE Double, which is a floating point number of
the specified precision plus special values  positive and negative
infinity, negative zero and not-a-number.

Currently in openmath the only way to express the special values is to
use the  hex attribute and then give the hex representation of the bits
in the IEEE representation of that number. This isn't particularly
intuitive (especially as we don't even give the examples in the spec to
save people working out what these values are).

There was a proposal during the drafting of OM 1 to allow another
attribute on OMF, something like <OMF symbolic="NaN"/> that would give a
human readable representation for these values. I'm not sure it ever got
explicitly rejected, but it didn't get done.

However times have changed and I think there is possibly now a better
alternative. We currently (in the OM 2 draft schema) specify the dec
attribute as a subtype of string, constrained by the regexp


  xsd:string {pattern = "(-?)([0-9]+)?(\.[0-9]+)?(e([+\-]?)[0-9]+)?"}


However it would be more natural (and probably more useful for tools
that generate code from the schema) to type the dec attribute as an
xsd:double

Apart from telling code to store these values as a double not as a
string, this would have the following effects on the valid XML
representations:

1) you could use "E" instead of "e"
   so 1E2 and 1e2 would both be allowed.
2) you could use special values INF -INF NaN 
   so <OMF dec="INF"/> would represent an IEEE double infinity.

The details of the XSD double type (which would also apply to our Relax
NG schema, which uses these types) are at the end of this message at the
URI given.

David



http://www.w3.org/TR/xmlschema-2/#double

3.2.5.1 Lexical representation

double values have a lexical representation consisting of a mantissa
followed, optionally, by the character "E" or "e", followed by an
exponent. The exponent ·must· be an integer. The mantissa must be a
decimal number. The representations for exponent and mantissa must
follow the lexical rules for integer and decimal. If the "E" or "e" and
the following exponent are omitted, an exponent value of 0 is assumed.

The special values positive and negative zero, positive and negative
infinity and not-a-number have lexical representations 0, -0, INF, -INF
and NaN, respectively.

For example, -1E4, 1267.43233E12, 12.78e-2, 12 and INF are all legal literals for double. 


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
--
om at openmath.org  -  general discussion on OpenMath
Post public announcements to om-announce at openmath.org
Automatic list maintenance software at majordomo at openmath.org
Mail om-owner at openmath.org for assistance with any problems



More information about the Om mailing list