Re: [xml] Getting crazy with float parsing
- From: Bjorn Reese <breese mail1 stofanet dk>
- To: "'xml gnome org'" <xml gnome org>
- Subject: Re: [xml] Getting crazy with float parsing
- Date: Mon, 06 May 2002 10:54:58 +0000
Daniel Veillard wrote:
I cannot get xmlXPatythStringEvalNumber to read "39413.80" as such
and not as 39413.800000000003 or some similary biased value, whatever
trick I play.
Any idea ? Would trio handle this correctly (assuming the string has
been first checked to be of the right format) ?
As Anthony and Aleksey already have pointed out, this is due to the
inherent inaccuracy of floating-point numbers. The link posted by
Aleksey describes the limitation in much detail.
The problem exposed by the bug report is that format-number() tries
to print more significant digits than can be represented by a double
(DBL_DIG, which usually is 15).
Although trio attempts to handle this situation (for example, it does
print 7/5 correctly, which my libc printf does not), it does not handle
all cases appropriately yet, and it also gets 39413.8 wrong. In fact,
this is an issue I have been looking at recently, but still haven't
found a solution for. If I do manage, I'll let you know.
this really drive me nuts,
Please allow me neutrality on the topic of your mental health ;)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]