ASF Bugzilla – Attachment 28859 Details for
Bug 53327
[PATCH] DoubleFormatUtil does not work with huge precision
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for the test case, which shows the issue
DoubleFormatUtilTest-patch.txt (text/plain), 1.48 KB, created by
Julien Aymé
on 2012-05-30 08:50:40 UTC
(
hide
)
Description:
Patch for the test case, which shows the issue
Filename:
MIME Type:
Creator:
Julien Aymé
Created:
2012-05-30 08:50:40 UTC
Size:
1.48 KB
patch
obsolete
>Index: test/java/org/apache/xmlgraphics/util/DoubleFormatUtilTest.java >=================================================================== >--- test/java/org/apache/xmlgraphics/util/DoubleFormatUtilTest.java (revision 1344130) >+++ test/java/org/apache/xmlgraphics/util/DoubleFormatUtilTest.java (working copy) >@@ -260,6 +260,9 @@ > * whereas DecimalFormat may have some formating errors regarding the last digit. > */ > private String refFormat(double value, int decimals, int precision) { >+ if (Double.isNaN(value) || Double.isInfinite(value)) { >+ return Double.toString(value); >+ } > buf.setLength(0); > BigDecimal bg = new BigDecimal(Double.toString(value)); > int scale = Math.abs(value) < 1.0 ? precision : decimals; >@@ -515,4 +518,18 @@ > long toStringDuration = System.currentTimeMillis() - start; > System.out.println("toString duration: " + toStringDuration + "ms to format " + (3 * nbTest) + " doubles"); > } >+ >+ public void testAllDoubleRanges() { >+ Random r = new Random(); >+ double value; >+ String expected, actual; >+ for (int i = -330; i <= 315; i++) { >+ value = r.nextDouble() * Math.pow(10.0, i); >+ for (int scale = 1; scale <= 350; scale++) { >+ expected = refFormat(value, scale, scale); >+ actual = format(value, scale, scale); >+ assertEquals(value, scale, scale, expected, actual); >+ } >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53327
: 28859 |
28860
|
28880
|
28891
|
28892