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

 
 

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

Submitted by:  None
Submitted on:  Wed 21 Oct 2015 02:07:52 AM UTC  
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Patch Submitted Assigned to:  Mike Miller <mtmiller>
Originator Name:  Michael Hirsch Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  4.0.0
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 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>
Project AdministratorIn charge of this item.
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 #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 jwe (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    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
    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.4