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 issues an error for non-intege


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #59719] dec2bin issues an error for non-integer inputs while Matlab does not
Date: Fri, 18 Dec 2020 14:37:08 -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

Follow-up Comment #7, bug #59719 (project octave):

just checking again on matlab compatibility as I was going to add the detail
to the help note, Matlab is, as usual, weird.  For positive numbers, dec2bin
applies fix(x) to the input to trim off fractions.  for negative numbers, it
appears to apply round(x).  **eyeroll**


>> dec2bin(12)
ans =
    '1100'
>> dec2bin(12.4)
ans =
    '1100'
>> dec2bin(12.6)
ans =
    '1100'

>> dec2bin(-12)
ans =
    '11110100'
>> dec2bin(-12.2)
ans =
    '11110100'
>> dec2bin(-12.6)
ans =
    '11110011'
>> dec2bin(-13)
ans =
    '11110011'


hooray consistency.

    _______________________________________________________

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]