bugGNU Octave - Bugs: bug #48591, function double on java objects.


bug #48591: function double on java objects.

Submitted by:  Ernst Reissner <ernstreissner>
Submitted on:  Fri 22 Jul 2016 12:06:57 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Fri 19 Aug 2016 05:00:33 PM UTC, comment #5: 

The patch below allows double(o) and int64(o)
for java objects o.
For the other types:
uint64 not supported because long does not support this fully.
All others may be created by casting.

(file #38284)

Ernst Reissner <ernstreissner>
Thu 11 Aug 2016 11:12:03 PM UTC, comment #4: 

I must admit, i did not find out how exactly to register.
I understood that some type conversion operation
shall be registered.
If you tell me the signature and how to register,
I can fill in the implementation.

-- or did I misunderstand something??

Ernst Reissner <ernstreissner>
Thu 11 Aug 2016 03:55:14 PM UTC, comment #3: 

No, the right approach would be to register the appropriate type conversion in the octave_java class. All octave_value types already have a robust type conversion system, it just needs to be implemented in each derived type as needed.

Mike Miller <mtmiller>
Project Administrator
Thu 11 Aug 2016 02:38:44 PM UTC, comment #2: 

Hello Mike,
I would like to provide a patch for this.

I would write an m-file double.m
delegating to the builtin function double
except for java types.

For those I would check for java.lang.Number
and then apply Number.doubleValue().

Is this acceptable??

Ernst Reissner <ernstreissner>
Wed 10 Aug 2016 12:14:50 AM UTC, comment #1: 

To make things more precise:
for java objects obj implementing java.lang.Number,
double(m) shall deliver some double.

for null values, one shall deliver []

What is not referred to is if it is no Number
but implements a method public double toDouble().
Currently, no effect but in future shall invoke this method.

This is worth another bug report.

Also this bugfix I shall defer until java sources are reformatted.

Ernst Reissner <ernstreissner>
Fri 22 Jul 2016 12:06:57 AM UTC, original submission:  


shows that in Matlab function double may be applied to java objects.

For Octave:

bd =

<Java object: java.math.BigDecimal>

octave:26> bd.doubleValue()
ans =  42
octave:27> class(ans)
ans = double
octave:28> double(bd)
error: invalid conversion from octave_java to scalar

this should not be.
In fact, double(bd) should invoke bd.doubleValue()
as it is an instance of java.lang.Number.

Ernst Reissner <ernstreissner>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #38284:  patchBug48591.patch added by ernstreissner (7KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by ernstreissner (Submitted the item)
  • -email is unavailable- added by ernstreissner

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-08-19 ernstreissner Attached File- => Added patchBug48591.patch, #38284
    2016-07-22 mtmiller CategoryOctave Function => Interpreter
        Item GroupNone => Matlab Compatibility
        StatusNone => Confirmed
        Release4.0.3 => dev
    2016-07-22 ernstreissner Carbon-Copy- => Added rei3ner@arcor.de

    Back to the top

    Powered by Savane 3.6