[erlang-bugs] bug in Jinterface sending doubles?

Sebastian Egner <>
Tue Dec 4 14:03:44 CET 2007


Hello!

Thanks for fixing it. Looking forward to R12, and using the following 
kludge until then:

    return OtpErlangDouble(value == 0 ? 1.0e-20 : value);

Cheers,

Sebastian.

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:
>   
>> Hello!
>>
>> 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: 
>> <<112,131,104,4,97,6,103,100,0,19,115,112,101,99,115,112,108,97,110,64,103,111,108,100,115,116,111,110,101,0,0,0,1,0,0,0,0,1,100,0,0,100,0,2,102,103,131,104,3,100,0,9,36,103,101,110,95,99,97,108,108,104,2,103,100,0,19,115,112,101,99,115,112,108,97,110,64,103,111,108,100,115,116,111,110,101,0,0,0,1,0,0,0,0,1,114,0,3,100,0,19,115,112,101,99,115,112,108,97,110,64,103,111,108,100,115,116,111,110,101,1,0,0,0,13,0,0,0,0,0,0,0,0,104,3,100,0,7,115,101,116,95,118,97,108,100,0,7,117,101,110,101,114,103,121,99,48,69,45,50,48,101,43,48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>
>>
>> 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]).
>> "blabla...uenergyc0E-20e+00...moreblabla"
>>
>> Sebastian.
>> _______________________________________________
>> erlang-bugs mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-bugs
>>     
>
>   


-- 

Dr. Sebastian Egner
Head of Software & 
Electronics Development

SPECS GmbH
Voltastr. 5
13355 Berlin
Germany

Phone: +49 (0)30 46 78 24 - 9210
Fax: +49 (0)30 46 42 083
E-Mail:    

Please visit www.specs.de

SPECS - YOUR COMPETENT PARTNER IN SURFACE ANALYSIS
----------------------------------------------------
SPECS Gesellschaft für Oberflächenanalytik und 
Computertechnologie mbH, CEO: Reinhard Lembke
Registered Office: Berlin
Companies Commercial Register No.: 93 HRB 21390 
Register Court: Charlottenburg
-----------------------------------------------------
This e-mail contains confidential and/or privileged
information. If you are not the intended recipient
(or have received this e-mail in error) please notify
the sender immediately and delete this e-mail. Any 
unauthorized copying, disclosure or distribution of
the material in this e-mail is strictly forbidden.




More information about the erlang-bugs mailing list