Author: msahyoun
Date: Sun Mar 11 20:36:23 2018
New Revision: 1826458

URL: http://svn.apache.org/viewvc?rev=1826458&view=rev
Log:
PDFBOX-4071, PDFBOX-4134: use Float.compare, use BigDecimal.valueOf

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetLineDashPattern.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetLineDashPattern.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetLineDashPattern.java?rev=1826458&r1=1826457&r2=1826458&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetLineDashPattern.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/state/SetLineDashPattern.java
 Sun Mar 11 20:36:23 2018
@@ -63,7 +63,7 @@ public class SetLineDashPattern extends
             if (base instanceof COSNumber)
             {
                 COSNumber num = (COSNumber) base;
-                if (num.floatValue() != 0)
+                if (Float.compare(num.floatValue(), 0) != 0)
                 {
                     allZero = false;
                     break;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java?rev=1826458&r1=1826457&r2=1826458&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSFloat.java Sun 
Mar 11 20:36:23 2018
@@ -90,17 +90,16 @@ public class COSFloat extends COSNumber
         double doubleValue = value.doubleValue();
         boolean valueReplaced = false;
         // check for huge values
-        if (floatValue == Float.NEGATIVE_INFINITY  || floatValue == 
Float.POSITIVE_INFINITY )
-        {
-            
+        if (Float.isInfinite(floatValue))
+        {      
             if (Math.abs(doubleValue) > Float.MAX_VALUE)
             {
-                floatValue = Float.MAX_VALUE * (floatValue == 
Float.POSITIVE_INFINITY ? 1 : -1);
+                floatValue = Float.MAX_VALUE * (Float.compare(floatValue, 
Float.POSITIVE_INFINITY) == 0 ? 1 : -1);
                 valueReplaced = true;
             }
         }
         // check for very small values
-        else if (floatValue == 0 && doubleValue != 0)
+        else if (Float.compare(floatValue, 0) == 0 && 
Double.compare(doubleValue, 0) != 0)
         {
             if (Math.abs(doubleValue) < Float.MIN_NORMAL )
             {
@@ -111,7 +110,7 @@ public class COSFloat extends COSNumber
         }
         if (valueReplaced)
         {
-            value = new BigDecimal(floatValue);
+            value = BigDecimal.valueOf(floatValue);
             valueAsString = removeNullDigits(value.toPlainString());
         }
     }


Reply via email to