[xml] xmlXPathStringEvalNumber vs. atof
- From: "Christopher R. Palmer" <crpalmer vivisimo com>
- To: xml gnome org
- Subject: [xml] xmlXPathStringEvalNumber vs. atof
- Date: Mon, 22 Jun 2009 15:31:16 -0400 (EDT)
I was just debugging at a very cryptic problem and traced it down to the fact that xmlXPathStringEvalNumber
does not parse different representations of the same number to the same floating point representation. For
example, 0.09 and 0.9e-1 have different floating point representations:
0.09 = 0.089999999999999996669
.9e-1 = 0.090000000000000010547
For comparison, atof returns the same value for those two strings (and for 9e-2 for that matter). While I
know that floating point equality should always be done with an epsilon to account for lack of precision, I
still expect
<xsl:value-of select="0.09 = .9e-1"/>
to be true. It returns false.
Is there any reason that libxml implements its own number parsing and doesn't use atof or sscanf to parse the
floating point numbers?
I'm using version 2.7.2, but I verified in the SVN repository that this code is unchanged in the trunk.
Cheers,
Chris.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]