[erlang-bugs] bug in Jinterface sending doubles?
Wed Dec 5 01:56:07 CET 2007
Did the ei get updated with IEEE format for doubles as well? It's quite
a waste to have them presently encoded using 32 bytes or more...
Raimo Niskanen wrote:
> Indeed there is (a bug).
> In the upcoming R12B release, Jinterface has been updated to
> use IEEE term format for Erlang marshalled data, so this
> bug should have vanished. We also now have at least one
> test case that echoes 0.0 (and other interesting floats)
> from Erlang via Jinterface.
> We had no such test case in R11B-5, and that was bad.
> The Jinterface code used java.math.BigDecimal and
> java.text.DecimalFormat to do the old (daft) marshalling
> that was based on C:s sprintf("%.20e", ...).
> It was written for Java 1.2.
> You seem to have run into a borderline case where
> d = roughly(0.0);
> BigDecimal b = new BigDecimal(d);
> b.signum() returns 0
> b = b.setScale(20,BigDecimal.ROUND_HALF_EVEN);
> b.toString() returns "0E-20" even though
> b.signum() returned 0 above
> So, since signum() is 0 b should be zero but
> toString() returns "0E-20" with setScale(20,...)
> sugessting v is just almost zero. toString() was
> supposed to return "0.00000000000000000000".
> Apparently in Java 1.3 java.math.BigDecimal(double d)
> changed behaviour to allow optional exponent sign.
> Perhaps something else changed too...
> Anyway... the bug should be gone in R12B.
> On Mon, Dec 03, 2007 at 05:15:30PM +0100, Sebastian Egner wrote:
>> There seems to be a bug in Jinterface (from R11B-5) related to sending
>> doubles from a Java node to an Erlang node:
>> =ERROR REPORT==== 3-Dec-2007::16:56:35 ===
>> Got invalid data on distribution channel, offending packet is:
>> My guess is that the offending value, the notorious (double)0.0, is not
>> properly encoded by OtpOutputStream.write_double():
>> > io:format("~s~n", [TheStuffAboveAsAListOfAsciiValues]).
>> erlang-bugs mailing list
More information about the erlang-bugs