[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #48013] Java integration: conversion to double
From: |
Carnë Draug |
Subject: |
[Octave-bug-tracker] [bug #48013] Java integration: conversion to double |
Date: |
Wed, 25 May 2016 18:13:13 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.8.0 |
Follow-up Comment #1, bug #48013 (project octave):
> Seemingly, a java-object is converted to double iff a method double
doubleValue() is defined, [...]
This is a bit more complex and supposedly Matlab compatible. See
http://hg.savannah.gnu.org/hgweb/octave/file/6cf6bc451eeb/libinterp/octave-value/ov-java.cc#l1156
But basically, java Numbers of any type are converted to double, while arrays
of java primitives are converted to octave arrays of matching types. We
previously had the bug that Octave did not make that conversion automatically
https://savannah.gnu.org/bugs/index.php?44882
See the Matlab documentation
http://uk.mathworks.com/help/matlab/matlab_external/handling-data-returned-from-a-java-method.html
which states:
> When a Java method is declared to return data of type java.lang.Object,
MATLAB converts its value, depending on its actual type, according to the
following table.
The table maps several (all?) java.lang.Number to class double. However, we
implemented this following the Matlab docs and then found that the reality is
a bit different. There is this extra note on the docs:
> There is no conversion if the method declaration specifies any subclass of
Object or array of Object. For example, if the method is declared to return
java.lang.String, then the return value remains a java.lang.String object and
is not automatically converted to char as is shown in the table.
Which I think clears the mistake we (actually I) made while reading the Matlab
docs. I'm pretty sure that note was not there 1 year ago.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?48013>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/