You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xmlgraphics.apache.org by bu...@apache.org on 2012/05/30 10:50:40 UTC

[Bug 53327] New: [PATCH] DoubleFormatUtil does not work with huge precision

https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

          Priority: P2
            Bug ID: 53327
          Assignee: general@xmlgraphics.apache.org
           Summary: [PATCH] DoubleFormatUtil does not work with huge
                    precision
          Severity: normal
    Classification: Unclassified
          Reporter: julien.ayme@gmail.com
          Hardware: PC
            Status: NEW
           Version: Trunk
         Component: Utilities
           Product: XMLGraphicsCommons

Created attachment 28859
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28859&action=edit
Patch for the test case, which shows the issue

The new DoubleFormatUtil class fails to format correctly doubles near
Double.MIN_VALUE (0 <= value <= 1e-300) with precision between 300 and 340.

I fixed the DoubleFormatUtil class and added a test case which shows the issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #12 from Julien Aymé <ju...@gmail.com> ---
Created attachment 28891
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28891&action=edit
Patch n.2 for the test case

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #4 from Glenn Adams <ga...@apache.org> ---
(In reply to comment #3)
> Thanks Glenn for applying the patch, everything seems fine after review.
> I'm closing the bug.

I encountered a failure when running junit on XGC today as follows:

Testcase: testAllDoubleRanges took 4.477 sec
        FAILED
value: 5.22534294505995E-4, decimals: 17, precision: 17
expected:<0.00052253429450[6]> but was:<0.00052253429450[599]>
junit.framework.ComparisonFailure: value: 5.22534294505995E-4, decimals: 17,
precision: 17 expected:<0.00052253429450[6]> but was:<0.00052253429450[599]>
        at
org.apache.xmlgraphics.util.DoubleFormatUtilTest.assertEquals(DoubleFormatUtilTest.java:223)
        at
org.apache.xmlgraphics.util.DoubleFormatUtilTest.testAllDoubleRanges(DoubleFormatUtilTest.java:531)

However, on a re-attempt, it did not fail. Perhaps this is because you use
random numbers in your test data.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #8 from Julien Aymé <ju...@gmail.com> ---
The aim of these two methods ("tooManyDigitsUsed" and "tooCloseTooRound") is to
force to use formatPrecise whenever we're not sure that formatFast will produce
the right result, but only when formatFast fails, since formatPrecise is much
slower (4 times) than formatFast.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #7 from Julien Aymé <ju...@gmail.com> ---
Created attachment 28880
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28880&action=edit
patch for both class and test case (DoubleFormatUtil.java and
DoubleFormatUtilTest.java)

Enhanced DoubleFormatUtil.tooCloseTooRound + DoubleFormatUtil.tooManyDigitsUsed

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Glenn Adams <ga...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Glenn Adams <ga...@apache.org> ---
applied at http://svn.apache.org/viewvc?rev=1345315&view=rev

thanks julien, please review and close if satisfied

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #15 from Julien Aymé <ju...@gmail.com> ---
At last, everything seems OK !

Thank you again Glenn.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #5 from Julien Aymé <ju...@gmail.com> ---
I'll investigate on this particular value + precision on monday.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #28859|0                           |1
           is patch|                            |

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #13 from Julien Aymé <ju...@gmail.com> ---
Created attachment 28892
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28892&action=edit
Patch n.2 for DoubleFormatUtil class

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Glenn Adams <ga...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #14 from Glenn Adams <ga...@apache.org> ---
apply patch n.2 at http://svn.apache.org/viewvc?rev=1346428&view=rev

thanks julien, please review and close

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #3 from Julien Aymé <ju...@gmail.com> ---
Thanks Glenn for applying the patch, everything seems fine after review.
I'm closing the bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |REOPENED
         Resolution|FIXED                       |---

--- Comment #11 from Julien Aymé <ju...@gmail.com> ---
I found the last (I hope) really rare bugs:
- The first one is due to long <-> double conversion error in
DoubleFormatUtil.format private method
- The second is due to a rounding error in double division in
DoubleFormatUtil.isRoundedToZero private method when rounding an exact value
5e-N value for certain value of N (when scale = N-1).

Patch for test case and class will follow.
Hopefully I won't find any bug concerning this class anymore.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

--- Comment #1 from Julien Aymé <ju...@gmail.com> ---
Created attachment 28860
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28860&action=edit
The patched DoubleFormatUtil

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CLOSED                      |REOPENED
         Resolution|FIXED                       |---

--- Comment #6 from Julien Aymé <ju...@gmail.com> ---
OK, I found the issue: in certain cases, the method "tooCloseTooRound" should
return true so that the "formatPrecise" method is used instead of the
"formatFast" method. So I tweaked the "tooManyDigitsUsed" and
"tooCloseTooRound" methods a bit, so that they perform better.

Patch will follow.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Glenn Adams <ga...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Glenn Adams <ga...@apache.org> ---
patch applied at http://svn.apache.org/viewvc?rev=1346092&view=rev

thanks julien, please verify and close

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


[Bug 53327] [PATCH] DoubleFormatUtil does not work with huge precision

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53327

Julien Aymé <ju...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #10 from Julien Aymé <ju...@gmail.com> ---
Verified, everything seems OK. Closing bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org