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);
}
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);