bugGNU Octave - Bugs: bug #47063, computation between single and...


bug #47063: computation between single and double performed with single precision

Submitted by:  CarnĂ« Draug <carandraug>
Submitted on:  Fri 05 Feb 2016 02:45:01 AM UTC  
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: WTF, Matlab?!?
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)

You are not logged in

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


Fri 18 Mar 2016 02:43:58 PM UTC, comment #4:

Since you asked on IRC...

It's better to write something like "perform mixed single-double ops in double precision (bug #...)" as the summary instead of "fix the bug...". Many patches are bug fixes and you're already tagging the bug report number so it's redundant to say "fix the bug".

Similarly, just write

* foo.h, foo.cc (function_name): New function.

instead of "add function ...". I think there are some tips about this in the Octave style guidelines in the Octave manual and also in the GNU coding standards document that it references.

John W. Eaton <jwe>
Project Administrator
Fri 18 Mar 2016 02:25:26 PM UTC, comment #3:

You are on the right track, but "demotion" means to reduce the rank of something, so that seems like the wrong word for a function that promotes float to double. It also makes no sense to have a demotion or promotion function that just makes a new value of the same type. Instead, if we are going to promote singles to doubles, we should remove the function that used to demote doubles to singles and add a promotion function for singles to doubles. And rename all of them, if we only need to do promotion. And you need to do it for matrix types as well, not just scalars.

But I'm still not sure this is a good idea. I'm not sure we should follow Matlab in this case.

John W. Eaton <jwe>
Project Administrator
Fri 18 Mar 2016 02:15:22 PM UTC, comment #2:

I have attached a file(patch) that solves this problem for single-double operations.
The idea is preventing double variables from being casted to single and on the other hand casting singles to doubles in order to perform the operation smoothly.

Amr Mohamed <amr_keleg>
Thu 10 Mar 2016 10:47:11 AM UTC, comment #1:

I would like towork on this bug can anyone guide me how interpreter works in octave.

SatyamPandey <spandey>
Fri 05 Feb 2016 02:45:01 AM UTC, original submission:

An operation between a double and a single returns a single for Matlab compatibility. However, it seems that Matlab actually performs the computations with doubles. See https://stackoverflow.com/questions/35213845/subtracting-double-precision-from-single-precision-gives-me-0-not-what-i-want

Carnë Draug <carandraug>
Project Member


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

Attach File(s):

Attached Files
file #36686:  ScalarFloatBugFix.diff added by amr_keleg (2KiB - text/x-patch - Kindly Review the attached patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by amr_keleg (Updated the item)
  • -unavailable- added by spandey (Posted a comment)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by jwe (Updated the item)
  • -unavailable- added by carandraug (Submitted the item)

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

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 18 Mar 2016 12:59:58 PM UTCamr_kelegAttached File-=>Added ScalarFloatBugFix.diff, #36686
    Sun 21 Feb 2016 10:16:50 PM UTCmtmillerCategoryNone=>Interpreter
      Operating SystemGNU/Linux=>Any
    Fri 05 Feb 2016 03:15:27 AM UTCjweItem GroupInaccurate Result=>WTF, Matlab?!?

    Back to the top

    Powered by Savane 3.1-cleanup1