bugGNU Octave - Bugs: bug #49192, dec2bin function does not behave...

 
 

bug #49192: dec2bin function does not behave the same as Matlab

Submitted by:  None
Submitted on:  Mon 26 Sep 2016 07:43:26 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: WTF, Matlab?!?
Status: Wont FixAssigned to: None
Originator Name: Jim HaberlyOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 29 Sep 2016 05:57:32 AM UTC, comment #4:

Matlab 2010b:

moreover

so dec2bin(x,y) = dec2base (x,2,y) unless x=0 & y=0

Anonymous
Tue 27 Sep 2016 05:44:04 PM UTC, comment #3:

This seems like an odd choice by Matlab. According to their own documentation:

So using n == 0 should imply that the result in binary will have 0 or more digits. Given that the decimal number 0 can be represented in binary by the decimal digit '0' it seems like the answer should have exactly one digit.

Just for fun, what does Matlab do for the following?

Octave's results are

which makes sense to me.

Rik <rik5>
Project Administrator
Tue 27 Sep 2016 11:12:08 AM UTC, comment #2:

Another hint to solve you issue in a Matlab compatible way, depending on your code, check for the second argument and make a branch. This should not be more expensive than calling a function without expecting any useful output, e.g.

Kai Torben Ohlhus <siko1056>
Project Member
Tue 27 Sep 2016 11:04:01 AM UTC, comment #1:

I would throw this bug report back to The Mathworks, e.g. in Matlab R2016a I get:

Here Octave looks more consistend, as it uses only dec2base in any case:

Kai Torben Ohlhus <siko1056>
Project Member
Mon 26 Sep 2016 07:43:26 PM UTC, original submission:

I just finished porting a complex model of an MPEG-2 video encoder originally written in Matlab. When executed on GNU Octave the model produced syntax errors in the output video stream. I traced this to the dec2bin() function.

Matlab: dec2bin(0,0) returns ''
Octave: dec2bin(0,0) returns '0'

When using dec2bin to produce character strings by concatenation, extra 0 bits were appearing in the result.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by siko1056 (Posted a comment)
  • -unavailable- added by None (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 15 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 29 Sep 2016 11:01:52 PM UTCrik5Open/ClosedOpen=>Closed
    Tue 27 Sep 2016 09:55:14 PM UTCmtmillerItem GroupMatlab Compatibility=>WTF, Matlab?!?
      Release4.0.2=>dev
      Operating SystemMicrosoft Windows=>Any
    Tue 27 Sep 2016 05:44:28 PM UTCrik5StatusNone=>Wont Fix
    Tue 27 Sep 2016 05:44:04 PM UTCrik5Priority3 - Low=>5 - Normal
      Item GroupWTF, Matlab?!?=>Matlab Compatibility
      StatusWont Fix=>None
      Release4.2.0-rc2=>4.0.2
      Operating SystemAny=>Microsoft Windows
    Tue 27 Sep 2016 11:04:01 AM UTCsiko1056Priority5 - Normal=>3 - Low
      Item GroupMatlab Compatibility=>WTF, Matlab?!?
      StatusNone=>Wont Fix
      Release4.0.2=>4.2.0-rc2
      Operating SystemMicrosoft Windows=>Any

    Back to the top


    Powered by Savane 3.1-cleanup1