bugGNU Octave - Bugs: bug #54602, (patch) fix behavior of octfile...

 
 

bug #54602: (patch) fix behavior of octfile signed int mod

Submitter:  Gene Harvey <gharveymn>
Submitted:  Fri 31 Aug 2018 05:13:13 AM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Gene Harvey Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 07 Sep 2018 04:54:00 PM UTC, comment #4: 

I pushed your patch to the stable branch here (https://hg.savannah.gnu.org/hgweb/octave/rev/1f52a96c8c21).

I added a commit message which follows the GNU style conventions.  I also added the bug number in the commit message summary which is an Octave convention so we can determine quickly what the code change was for.  Finally, I added some built-in self tests (BIST) so that if we accidentally revert this behavior we will find it quickly when running the test suite.

In a separate changeset (https://hg.savannah.gnu.org/hgweb/octave/rev/5f22779e6857) I added you to the list of contributors to Octave.  Welcome aboard!

Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Fri 07 Sep 2018 03:24:19 AM UTC, comment #3: 

@Rik: Great, happy to help.

Submitting the patch with my credentials is fine. I'm new around here and would like to help out more, any ideas on how to do that?

Gene Harvey <gharveymn>
Thu 06 Sep 2018 03:21:43 PM UTC, comment #2: 

@Gene: I tested your patch and it works fine and the test suite for Octave passes with no new failures.

We like to recognize those who help out Octave.  We can add your name to the list of contributors at the front of the Octave manual.  Also, when checking in the code to Mercurial we typically use a name and and e-mail address.  The name, for credit, and the e-mail address in case a problem is discovered later on so that we can reach you.  Alternatively, we have contributors who wish to remain anonymous or simply don't want to engage with the project any more than providing a patch.  In that case I can check the code in under my own credentials.  Let me know how you would like to proceed.

Rik <rik5>
Group administrator
Thu 06 Sep 2018 04:42:58 AM UTC, comment #1: 

Confirmed.  A simple test is to check the results for doubles.


octave:15> mod (125, 25)
ans = 0
octave:16> mod (-125, 25)
ans = 0
octave:17> mod (-125, -25)
ans = -0
octave:18> mod (int8(-125), int8(-25))
ans = -25


The result for int8 integers should match the result for doubles which are also perfect integers.

Rik <rik5>
Group administrator
Fri 31 Aug 2018 05:13:13 AM UTC, original submission:  

This is a small fix to the behavior of the octfile implementation of the signed mod function.

Currently the function returns y if x%y==0 and y<0. Example: x=-125, y=-25 will return -25 instead of 0. The patch changes behavior to return 0.

I've included a few files to show the current behavior and how it differs from MATLAB.

Gene Harvey <gharveymn>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #44903:  intmodpatch.patch added by gharveymn (831B - application/octet-stream)
file #44904:  testmatlab.m added by gharveymn (528B - text/plain)
file #44905:  modtest.cpp added by gharveymn (236B - text/plain)
file #44906:  testoctave.m added by gharveymn (557B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gharveymn (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 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-07 rik5 StatusPatch Reviewed Fixed
        Open/ClosedOpen Closed
    2018-09-06 rik5 StatusPatch Submitted Patch Reviewed
    2018-09-06 rik5 CategoryNone Libraries
        Item GroupMatlab Compatibility Incorrect Result
        StatusNone Patch Submitted
        Releaseother dev
    2018-08-31 gharveymn Attached File- Added intmodpatch.patch, #44903
        Attached File- Added testmatlab.m, #44904
        Attached File- Added modtest.cpp, #44905
        Attached File- Added testoctave.m, #44906

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code