Project

Profile

Help

Bug #759

closed

Float-to-string conversion problems

Added by Anonymous about 18 years ago. Updated about 12 years ago.

Status:
Closed
Priority:
High
Assignee:
-
Category:
Performance
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Legacy ID:
sf-1439685
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

SourceForge user: mhkay

In 8.7 a new module was introduced to handle

conversions from float/double to string. This module

can cause performance problems.

Because the algorithm uses floating-point arithmetic,

rounding errors can sometimes accumulate, and to

compensate for this, the algorithm applies a small

correction to the result as the last thing it does.

However, there are some cases where the number to be

formatted is close to a power of 10 (for example the

float 0.00001) where the rounding error causes the

intermediate result to be out by a factor of ten and in

this case the minal adjustment is applied millions of

times, causing chronically poor performance.

The algorithm used by this module,

FloatingPointConverter, was from a Java text book by

Jack Shirazi, but it has been found inadequate to meet

the requirements of the XPath conversion rules. I have

therefore implemented a new version of this module,

using an algorithm publish by Guy Steele and Jon White

in SIGPLAN '90: this algorithm uses integer arithmetic

only and gives much more reliable (and faster) results.

The new module is attached, and should be used as a

plug-in replacement for

net.sf.saxon.value.FloatingPointConverter.java

Michael Kay


Files

FloatingPointConverter.java (9.56 KB) FloatingPointConverter.java Anonymous, 2006-02-27 15:19

No data to display

Please register to edit this issue

Also available in: Atom PDF