From c0d09e1714d71bcf2cc7e0982f3a843f0283f397 Mon Sep 17 00:00:00 2001 From: Glen Stampoultzis Date: Tue, 27 Aug 2002 10:29:52 +0000 Subject: [PATCH] Removed the call to doubleToRawLongBits() 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 | 6 +++++- src/testcases/org/apache/poi/util/TestLittleEndian.java | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) 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); -- 2.39.5