]> source.dussan.org Git - poi.git/commitdiff
Removed the call to doubleToRawLongBits()
authorGlen Stampoultzis <glens@apache.org>
Tue, 27 Aug 2002 10:29:52 +0000 (10:29 +0000)
committerGlen Stampoultzis <glens@apache.org>
Tue, 27 Aug 2002 10:29:52 +0000 (10:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352828 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/util/LittleEndian.java
src/testcases/org/apache/poi/util/TestLittleEndian.java

index 935fd5a6682960c9d4cfc15cf1363f8a2cb14bb6..d7cdc18426c1a98b6748ef987084472c3e268373 100644 (file)
@@ -386,7 +386,11 @@ public class LittleEndian
 
     public static void putDouble(final byte[] data, final int offset,
             final double value) {
-        putNumber(data, offset, Double.doubleToRawLongBits(value), DOUBLE_SIZE);
+        // Excel likes NaN to be a specific value.
+        if (Double.isNaN(value))
+            putNumber(data, offset, -276939487313920L, DOUBLE_SIZE);
+        else
+            putNumber(data, offset, Double.doubleToLongBits(value), DOUBLE_SIZE);
     }
 
 
index 56d830cc0e873dde58dbf7f2af370d4b65bd1d73..406737bdb2a73ef7fef5a3b8b59bb19ab97cd13b 100644 (file)
@@ -166,9 +166,6 @@ public class TestLittleEndian
         assertEquals(_doubles[ 1 ], LittleEndian.getDouble( _double_array, LittleEndian.DOUBLE_SIZE), 0.000001);
         assertTrue(Double.isNaN(LittleEndian.getDouble(_nan_double_array)));
 
-        // does not work.  apparently nan does not always equal nan!
-        //assertEquals(_doubles[ 2 ], LittleEndian.getDouble(_nan_double_array), 0.000001);
-
         double nan = LittleEndian.getDouble(_nan_double_array);
         byte[] data = new byte[8];
         LittleEndian.putDouble(data, nan);