bugGNU Octave - Bugs: bug #46015, Octave has rounding error that...

 
 

bug #46015: Octave has rounding error that Matlab does not

Submitter:  None
Submitted:  Mon 21 Sep 2015 09:29:54 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Bradlee Speice Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.1
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 24 Sep 2015 02:37:21 PM UTC, comment #4: 

That makes sense. I didn't change how Matlab was displaying anything, so that's where the confusion came from. I'll keep the format in mind for the future, thank you for your help on this.

Anonymous
Tue 22 Sep 2015 12:03:54 PM UTC, comment #3: 

Matlab says:

>> 100 .998 1.009 * .998


ans =

  100.4968

>> format long
>> ans


ans =

     1.004968036000000e+02

So, no problem.

Michael Godfrey <godfrey>
Group Member
Tue 22 Sep 2015 12:50:50 AM UTC, comment #2: 

Yeah I'm going to agree with oheim, it's a default output format issue, not a problem with any calcuation. The actual stored value is correct, just not shown to the precision you expect by default, but should be matching Matlab.

Mike Miller <mtmiller>
Group Member
Mon 21 Sep 2015 09:33:24 PM UTC, comment #1: 

Maybe this is just an output format issue. I can see the following in Octave:


>> 100 * .998 * 1.009 * .998
ans =  100.50
>> format long
>> ans
ans =  100.496803600000


Did you use format short in Matlab?

Oliver Heimlich <oheim>
Mon 21 Sep 2015 09:29:54 PM UTC, original submission:  

So I have a pretty straightforward issue. The following equation produces different results between Octave and Matlab:

100 .998 1.009 * .998

Octave produces a result of 100.50
Matlab produces a (correct) result of 100.4968.

I'm guessing the rounding error appears in between multiplications, but it seems strange that Octave would have this issue, no other calculator I tried had the same problem.

Do I need to set the session precision higher or similar? I find that this behavior as a default is an issue.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by oheim (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-09-22 mtmiller StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code