Re: [xml] Getting crazy with float parsing



Bjorn Reese wrote:

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.

The latest baseline of trio (v 1.7) now handles these numbers appropriately.
Consider the following statement

  printf("%30.24f\n%30.24f\n%30.24f\n", 39413.80, 1.4, (2.0/3.0));

The libc printf on my machine outputs

  39413.800000000002910383045673
      1.399999999999999911182158
      0.666666666666666629659233

whereas trio outputs

  39413.800000000000000000000000
      1.400000000000000000000000
      0.666666666666667000000000

Let me know if you want to use this, and I'll upgrade libxml to the latest
trio baseline.



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