*From*: Bjorn Reese <breese mail1 stofanet dk>*To*: xml gnome org*Subject*: Re: [xml] XPath numbers and exponential notation*Date*: Tue, 24 Apr 2001 18:02:41 +0000

Thomas Broyer wrote: [ Subject line adjusted ]

The XPath spec states (4.2 String Functions, string()) that a float should be represented with "as many, but only as many, [] digits as are needed to uniquely distinguish the number from all other IEEE 754 numeric values."

Although I agree what we could be more in alignment with the above quote, it does not solve the problem. Consider the following expression string(number(999999999)*number(999999999)) How should the outcome look? The accurate result is 999999998000000001, which is 18 digits. However, IEEE 754 can only accurately represent 16 digits, so the result will be shown as 9999999980000000xx, where 'xx' is garbage. With scientific notation the outcome would be 9.99999998e17.

It also means that big numbers cannot be represented accurately with the regular 9.9 floating point notation.What's this notation?

The normal non-scientific notation, i.e. without exponent.

If we were going to try this, the least significant digit would be garbage.See above.

And below.

Notice that the XPath spec also have a note saying that "the string function is not intended for converting numbers into strings for presentation to users." Thus, whether the output has some garbage isn't really annoying.

Thus, the output of scientific notation isn't really annoying either. Scientific notation will at least make it perfectly clear to you that the least significant digits are not available.

I'm feeling like Daniel and would prefer an extension function or at least a flag (similar to SAX properties) to switch between XPath 1.0 and partial XPath 2.0 conformance.

I am still accepting patches.

**References**:**Re: [xml] core dump buglet in libxml2 when setting new prop***From:*Thomas Broyer

[Date Prev][Date Next] [Thread Prev][Thread Next] [Thread Index] [Date Index] [Author Index]