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

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

[Octave-bug-tracker] [bug #59719] dec2bin does not work for real numbers


From: Peter Kempter
Subject: [Octave-bug-tracker] [bug #59719] dec2bin does not work for real numbers (compared to matlab)
Date: Fri, 18 Dec 2020 03:28:53 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36

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

                 Summary: dec2bin does not work for real numbers (compared to
matlab)
                 Project: GNU Octave
            Submitted by: ket3r
            Submitted on: Fri 18 Dec 2020 08:28:52 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Peter Kempter
        Originator Email: 
             Open/Closed: Open
                 Release: 6.1.0
         Discussion Lock: Any
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

= Problem =
Calling dec2bin only works for natural numbers. 

Calling it for e.g. _8.9_ produces an error telling me _input must be real
non-negative integers_. Matlab on the other hand just floors the _8.9_ to _8_
and then converts it with dec2bin

= Steps to reproduce =
Use dec2bin for 8 and 8.9 in Matlab (my Version is 2019b) and in Octave
(6.1.0).

== (Non-matlab-compatible) Octave Output ==

>> dec2bin(8)
ans = 1000
>> dec2bin(8.9)
error: dec2base: input must be real non-negative integers
error: called from
    dec2base at line 76 column 5
    dec2bin at line 52 column 7


== Matlab Output ==

>> dec2bin(8)
ans =
    '1000'
>> dec2bin(8.9)
ans =
    '1000'


= Expected behavior =
Two options:
1. (Preferred one) Floor the input of dec2bin so it is compatible to Matlab
2. Change the error message of dec2base to something more meaningful. E.g.
_input must be a natural number_




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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