Re: [xml] xpath's number function



On Thu, 2004-10-07 at 22:32, Agustin Villena wrote:

       We have a doubt about the xpath's number() function: If we process a 
ten digits number, the function outputs it in exponential format.
    Is this limit the w3c standard? Is there any standard function (like 
"number") that processes large numbers without the exponential formatting 
issue?

Before I address your questions, I want to point out that number()
converts a string into a number. I assume that you are talking about
string() (or a string cast), which converts a number into a string.

The problem is a bit complicated (as are most issues concerning
floating-point numbers).

The XPath spec mandates IEEE 754 numbers. IEEE 754 is the standard
for floating-point numbers the most CPU/FPUs use these days. This
standard uses a fixed number of bits to represent floating-point
numbers; typically 15. This means that if you have numbers with
more than 15 significant digits, the least significant digits will
be lost. In other words, if you have a 30 digit number, only the
first 15 digits will have a meaningful value. The XPath spec does
not address this issue.

Libxml works around this problem by using scientific notation for
large numbers (which, by the way, is the same solution as the C
programming language uses).

Currently, libxml switches to scientific notation if there are
more than 9 digits in the numbers. I have forgotten why the number
is 9, and not higher. It may be possible to increase this number,
but it cannot go beyond 15 (DBL_DIG).





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