floats
Stephen Buswell
sb at stilo.demon.co.uk
Wed Jul 14 18:05:50 CEST 1999
[bruce miller wrote:]
>II) XML Encoding (Section 4.1.2)
>
> Floating-point numbers are encoded using the OMF element in one
> of two forms:
> a) The XML-attribute hex [Note 1] provides 16 characters [0-9,A-F]
> [...]
> b) The value may be expressed in base 10, using the common syntax
> (-?)([0-9]+)?("."[0-9]+)?(e([+-]?)[0-9]+)?
> in the content of the OMF element.
The decimal form is currently <OMF dec="1345678.9876543"/>. The proposal
suggests
that hex values are in an attribute, but decimal values in the element content.
This is achievable, although probably incompatible with some existing
implementations
of the OM syntax. I would prefer both to have the same form (in the
attribute for
historical consistency).
> The optional attribute
> prec specifies the precision of the number, and may take on
> of the following values:
> n : ([0-9]+) n decimal digits of the mantissa are
> assumed to be correct. n can be greater than the
> length of the mantissa, trailing `0's are implied.
> Conversely, more than n digits can be given in
> order to assist in reconstructing a more faithful
> internal (eg. binary) representation.
> exact : an exact (rational) value is presented [Note 3]
> asis : exactly the given digits are correct. [Note 4]
> If the prec attribute is missing, asis is assumed
> (or exact, or ? [Note 5])
>
> Attribute dec is deprecated.
I think we need dec for decimal values (see above)
> [*** NOTES ***
> *1*: I would prefer the attribute IEEE over hex, but this would
> break compatibility.
So would I, especially as, if I understand things correctly, the value of
the hex attribute is not necessarily the hex value of the number in question.
We could add 'ieee' as an additional attribute, and deprecate 'hex'
> *2*: Am I misreading the current draft spec, or is the value
> of the hex attribute to be given least significant byte first?
> The binary encoding specifies most significant byte first!
This appears to be what the current spec. says.
> *3*: This seems like a useful concept to represent, but there
> certainly is NO expectation that an application has a
> representation for it.
Why say it is a float in this case, rather than encode it as a rational ?
(Presumably there is some deep reason why float is a primitive type & rational
is not ?)
> *4*: "asis" is obviously a poor name; is it even needed?
This seems the natural assumption in the absence of any
other information.
> *5*: what should be the default?
> ]
'asis', or 'implied-precision' or something like that
We could also add some way of indicating a probability distribution
around the given value (cfr the posting from Mike Richardson)
--Stephen
Stephen Buswell
Stilo Technology
sb at stilo.demon.co.uk
More information about the Om
mailing list