[ 
https://issues.apache.org/jira/browse/XGC-109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16047564#comment-16047564
 ] 

Julien Gouesse commented on XGC-109:
------------------------------------

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- a/DoubleFormatUtil
+++ b/DoubleFormatUtil
@@ -353,9 +353,13 @@
      */
     private static boolean tooManyDigitsUsed(double source, int scale) {
         // if scale >= 308, 10^308 ~= Infinity
+        source = Math.abs(source);
+        if (source != 0) {
         double decExp = Math.log10(source);
         return scale >= 308 || decExp + scale >= 14.5;
     }
+        return false;
+    }
 
     /**
      * Returns true if the given source is considered to be too close
@@ -369,7 +373,7 @@
         source = Math.abs(source);
         long intPart = (long) Math.floor(source);
         double fracPart = (source - intPart) * tenPowDouble(scale);
-        double decExp = Math.log10(source);
+        double decExp = source == 0 ? 0 : Math.log10(source);
         double range = decExp + scale >= 12 ? .1 : .001;
         double distanceToRound1 = Math.abs(fracPart - Math.floor(fracPart));
         double distanceToRound2 = Math.abs(fracPart - Math.floor(fracPart) - 
0.5);

> Exception in DoubleFormatUtil.tooManyDigitsUsed with Windows 64 bits / Java 8
> -----------------------------------------------------------------------------
>
>                 Key: XGC-109
>                 URL: https://issues.apache.org/jira/browse/XGC-109
>             Project: XMLGraphicsCommons
>          Issue Type: Bug
>          Components: utilities
>    Affects Versions: trunk, 2.2
>         Environment: Windows 64 bits  / Java 8 64 bits
>            Reporter: Valery LEPRETRE
>             Fix For: trunk, 2.2
>
>         Attachments: DoubleFormatUtil.java
>
>
> Hi,
> I was recently confronted to this trouble with Windows 64 bits / Java 8:
> When you start a JVM (Java 8 / 64 bits) from a C, C++ (or other non Java) 
> program using xml-graphics to convert a svg to pdf, a crash occurs with  
> number 0 or negative in DoubleFormatUtil.tooManyDigitsUsed.
> It's because the VM is not handling correctly Floating point exception (fixed 
> in Java 9)
> To avoid this error, I propose to protect the call of function 
> tooManyDigitsUsed



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to