[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #59466] [octave forge] (communications) de2bi
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #59466] [octave forge] (communications) de2bi improper input handling |
Date: |
Mon, 16 Nov 2020 07:40:08 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?59466>
Summary: [octave forge] (communications) de2bi improper input
handling
Project: GNU Octave
Submitted by: nrjank
Submitted on: Mon 16 Nov 2020 07:40:05 AM EST
Category: Octave Forge Package
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Unexpected Error or Warning
Status: None
Assigned to: None
Originator Name: Nicholas Jankowski
Originator Email:
Open/Closed: Open
Release: 5.2.0
Discussion Lock: Any
Operating System: Microsoft Windows
_______________________________________________________
Details:
as pointed out in a recent question over on Stack overflow [1], the de2bi
function in the Communications package produces errors for inputs that should
be handled without error, and that don't produce errors in Matlab. Unsure
whether this is a change to Matlab input handling to be more flexible, but
currently results in incompatible code and an unexpected warnings.
details:
de2bi takes up to 4 inputs:
de2bi(decimal_input,num_columns,base_for_conversion,msb_flag)
the inputs must be in order, but the msb flag as the only non-numeric input
can be 2nd, 3rd, or 4th (nothing may follow it). the first non-string input
after the decimal input is assumed to be the number of output columns, so
specifying the base requires columns also be specified. Matlab allows you to
use [] as a placeholder for either number of columns or base.
e.g., on Matlab 2020a:
>> de2bi(19)
ans =
1 1 0 0 1
>> de2bi(19,'left-msb')
ans =
1 0 0 1 1
>> de2bi(19,3,'left-msb')
Error using de2bi (line 162)
Specified number of columns in output matrix is too small.
>> de2bi(19,5,'left-msb')
ans =
1 0 0 1 1
>> de2bi(19,[],'left-msb')
ans =
1 0 0 1 1
>> de2bi(19,[],[],'left-msb')
ans =
1 0 0 1 1
>> de2bi(19,[],5,'left-msb')
ans =
3 4
However, on Octave 5.2.0 with Communications 1.2.2:
>> de2bi(19)
ans =
1 1 0 0 1
>> de2bi(19,'left-msb')
error: ones: invalid data type specified
error: called from
de2bi at line 79 column 5
>> de2bi(19,3,'left-msb')
ans =
0 1 1
>> de2bi(19,3,'right-msb')
ans =
1 1 0
>> de2bi(19,5,'left-msb')
ans =
1 0 0 1 1
>> de2bi(19,[],'left-msb')
ans =
1 0 0 1 1
>> de2bi(19,[],[],'left-msb')
ans = [](0x0)
>> de2bi(19,[],5,'left-msb')
ans =
3 4
I don't think it's an issue that Octave allows specifying fewer columns than
needed to fit the whole number, but it looks like the rest could be fixed by
revisiting the input parsing for the function.
will take a look later today.
[1] https://stackoverflow.com/a/64857872/4598449
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?59466>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #59466] [octave forge] (communications) de2bi improper input handling,
Nicholas Jankowski <=