From: Glen Stampoultzis Date: Tue, 27 Aug 2002 10:29:52 +0000 (+0000) Subject: Removed the call to doubleToRawLongBits() X-Git-Tag: REL_1_10~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c0d09e1714d71bcf2cc7e0982f3a843f0283f397;p=poi.git Removed the call to doubleToRawLongBits() git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352828 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/util/LittleEndian.java b/src/java/org/apache/poi/util/LittleEndian.java index 935fd5a668..d7cdc18426 100644 --- a/src/java/org/apache/poi/util/LittleEndian.java +++ b/src/java/org/apache/poi/util/LittleEndian.java @@ -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); } diff --git a/src/testcases/org/apache/poi/util/TestLittleEndian.java b/src/testcases/org/apache/poi/util/TestLittleEndian.java index 56d830cc0e..406737bdb2 100644 --- a/src/testcases/org/apache/poi/util/TestLittleEndian.java +++ b/src/testcases/org/apache/poi/util/TestLittleEndian.java @@ -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);