bugGNU Octave - Bugs: bug #46262, [octave forge] (communications)...

 
 

bug #46262: [octave forge] (communications) de2bi: patch for bizarre results with non-float input

Submitter:  None
Submitted:  Wed 21 Oct 2015 02:07:52 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Michael Hirsch Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 01 Apr 2021 04:05:28 PM UTC, comment #7: 

The bug can be closed now, but I don't have authority to do it, so we'll have to wait for someone who does.

Nir Krakauer <nir_krakauer>
Thu 01 Apr 2021 10:15:41 AM UTC, comment #6: 

Nir,

Thank you for adding this patch.

How does the bug closure process work?
Does a new version of the package need to be available first?


Anonymous
Wed 31 Mar 2021 01:04:31 AM UTC, comment #5: 
Nir Krakauer <nir_krakauer>
Sun 28 Mar 2021 01:27:52 PM UTC, comment #4: 

I updated to nrjank's version which fixes bug #59466.

It looks like that patch did not fix this issue.

de2bi(uint8(31))
ans =

  1  2  2  2  2


Making the changes in Michael's patch

de2bi(uint8(31))
ans =

  1  1  1  1  1


Comment #2 also fixed this issue, however I followed the patch since it gave some more tests.

The attached patch is just Michael's patch applied to njank's version

(file #51152)

Anonymous
Mon 16 Nov 2020 12:21:41 PM UTC, comment #3: 

this bug appears to still be present in Octave 5.2.0 and Communications 1.2.2

Nicholas Jankowski <nrjank>
Group Member
Fri 04 Jan 2019 07:35:23 AM UTC, comment #2: 

The root cause of this problem is in the line

  b = floor (rem (d, p*power) ./ power);

When d is an integer type the result is rounded before the floor operation can truncate it.  The patch attached with the original bug report addressed this problem by forcing the divide to be done as floating point, so that rounding does not occur before the floor operation.

That is fine for integer types with fewer than 54 bits.  Larger integers (i.e., uint64) that use more than 54 bits cannot be represented exactly in a double precision floating point number, so the answer will be incorrect.

Changing the above line to:

  b = idivide(rem (d, p*power), power, 'floor')

seems to fix the problem for the limited cases I have tried.

Anonymous
Wed 21 Oct 2015 02:06:24 PM UTC, comment #1: 

Thanks very much for the bug report and the patch. I'll take a look at this fix soon.

Mike Miller <mtmiller>
Group Member
Wed 21 Oct 2015 02:07:52 AM UTC, original submission:  

A patch is attached for octave-communications-1.2.1 de2bi.m that fixes two issues

1) bizarre results with non-float input. Example:

>> de2bi(uint8(31))

ans =

  1  2  2  2  2

2) makes output class match input class (behaves like competitor)
Example:
class(de2bi(uint8(32)))
ans = uint8

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51152:  de2bi.patch added by None (1KiB - text/x-patch)
file #35247:  de2bi.patch added by None (813B - text/x-patch - patch to fix incorrect output on non-float input, and make output class match input class)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by nir_krakauer (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-01 mmuetzel StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2021-03-28 None Attached File- Added de2bi.patch, #51152
    2020-02-28 mtmiller Assigned tomtmiller None
    2018-07-02 jwe Summary[octave-forge] (communications) de2bi: patch for bizarre results with non-float input [octave forge] (communications) de2bi: patch for bizarre results with non-float input
    2017-08-11 jwe Summarycommunications package: de2bi: patch for bizarre results with non-float input [octave-forge] (communications) de2bi: patch for bizarre results with non-float input
    2015-10-21 mtmiller StatusNone Patch Submitted
        Assigned toNone mtmiller
        Summaryoctave-communication 1.2.1 de2bi: patch for bizarre results with non-float input communications package: de2bi: patch for bizarre results with non-float input
    2015-10-21 None Attached File- Added de2bi.patch, #35247

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code