title: matlab - How to get int64 from a Java method returning a long?
body: <p>According to <a href="http://www.mathworks.com.au/help/matlab/matlab_external/handling-data-returned-from-a-java-method.html">Matlab documentation</a>, when a Java method returns a <code>long</code>, it is converted to a <code>double</code> before being assigned in Matlab.</p>
  
  <p>Precision has been lost. I am interested in the lower digits of the <code>long</code> returned by the Java method. A <code>double</code> cannot represent them, but Matlab's <code>int64</code> can. (This is clear by considering that both types have 64 bits, and a <code>double</code> uses some of them to represent the exponent.)</p>
  
  <p>If I had control of the Java code, I could return an array with one element, containing the <code>long</code> — in this case Matlab keeps them as <code>int64</code>s, but in my case I'm calling a library function.</p>
  
  <p>Currently, the best way I can see is writing a wrapper in Java that will call the method and return the answer in an array. But there are portability issues with this approach. Is there a better way?</p>