octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #48013] Java integration: conversion to double


From: Ernst Reissner
Subject: [Octave-bug-tracker] [bug #48013] Java integration: conversion to double
Date: Thu, 26 May 2016 20:12:26 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0

Follow-up Comment #3, bug #48013 (project octave):

Well, if I have a look at 
http://hg.savannah.gnu.org/hgweb/octave/file/6cf6bc451eeb/libinterp/octave-value/ov-java.cc#l1156,

then I can see that octave converts a java object of type extending
java/lang/Number 
automatically to a double invoking method doubleValue(). 

According to the Matlab documentation, 
only very few types extending java/lang/Number 
are converted this way, namely those autoboxing the builtin types, 
i.e. Double behaves like double Float like float and so on. 

In contrast to this, java/math/BigDecimal, 
also extending java/lang/Number is not converted that way. 
This seems a detail only but is vital: 
BigDecimal avoids errors by conversion of 10adic to binary format. 
It allows to represent 0.2 without a failure. 
Autoconversion would not even allow to add 0.2+0.2=0.4 without a failure
because 0.2 would be converted back prior to addition. 
Things like those are important whenever one tries to implement some kind of
arithmetics, be it intervals, rational arithmetics or something else (which i
do). 

For objects extending java/lang/Number 
THE USER may convert the type using EXPLICITLY 
the matlab function double. 
The documentation is quite implicit, but I suppose, 
that the double function does nothing but invoking the java method
doubleValue(). 

I hope that the few lines above contribute to clarification. 

I think, the octave documentation should be extended 
including the conversion process from octave to java 
and vice versa as the matlab-documentation does. 
By the way, the old java-package from michael goffioul did include some of
this stuff which was not transported into the octave documentation when
including the package. 



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48013>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]