Re: [xml] More floating point "issues"



On Tue, Apr 09, 2002 at 03:27:24PM +0100, Richard Jinks wrote:
Hi

Last problem with floating point numbers, I hope...
(Well, these are the last of the regression tests I've been playing with,
anyway!)

According to the XPath spec, scientific notation is not allowed at all 
(i.e. 1e-4).
This applies both to converting numbers to strings, and strings to numbers.
Libxml currently outputs "1e-6" instead of "0.000001", and will happily
accept "1e-6" as a valid number instead of converting it to "NaN".

  Was beaten to death one year ago. Yes we know it's a violation
of the XPath 1.0 spec, it's part of XPath 2.0 requirement to support those,
and in this specific case I traded conformance for a more sensible behaviour.

Also, when converting from numbers to strings ONLY, it is valid to have a
number with no digits before or after the decimal point (but not both),
i.e. ".4" and "4." are both valid, "." isn't.
Of these cases, libxml only complains about numbers with no leading digits
(".4") giving an "Invalid expression" error.

  Hum, okay,

I've done a fix for all three cases, but I wanted to check with you about
the problem with scientific numbers, esp since you've put specific cases 
in the code to handle them. My guess is that libxml should probably never 
output numbers in this format (i.e. should always output "0.000001"), 
but do you want to stop this notation being used when inputting numbers?

  Basically patch gratefully accepted for the 2 latter cases but the first 
one would be a problem I'm afraid,

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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