octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #58147] Matlab 2020 compatibility: dec2bin, de


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #58147] Matlab 2020 compatibility: dec2bin, dec2hex shouldn't error on negative inputs
Date: Thu, 9 Apr 2020 12:06:10 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?58147>

                 Summary: Matlab 2020 compatibility: dec2bin, dec2hex
shouldn't error on negative inputs
                 Project: GNU Octave
            Submitted by: nrjank
            Submitted on: Thu 09 Apr 2020 12:06:08 PM EDT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Nicholas Jankowski
        Originator Email: 
             Open/Closed: Open
                 Release: 5.2.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

Matlab 2020a has the following in the release notes:


dec2bin and dec2hex Functions: Accept negative numbers as input arguments


Octave 5.2.0 currently passes both inputs to dec2base which produces an
error:

>> dec2bin(-3)
error: dec2base: input must be real non-negative integers
error: called from
    dec2base at line 72 column 5
    dec2bin at line 48 column 7
>> dec2hex(-3)
error: dec2base: input must be real non-negative integers
error: called from
    dec2base at line 72 column 5
    dec2hex at line 48 column 7


in matlab 2020a, it accepts the inputs, although I don't quite follow the
logic, and they seem to do some conversion before passing to dec2base, since
that still rejects negative input:


>> dec2hex(-3)
ans =
    'FD'
>> hex2dec(ans)
ans =
   253
>> dec2bin(-3)
ans =
    '11111101'
>> bin2dec(ans)
ans =
   253
>> dec2base(-3,2)
Error using dec2base (line 22)
First argument must be an array of integers, 0 <= D <= flintmax. 





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58147>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]