[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #57704] Exactly Matlab compatible behavior for
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #57704] Exactly Matlab compatible behavior for rats? |
Date: |
Thu, 30 Jan 2020 21:37:49 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 |
Follow-up Comment #1, bug #57704 (project octave):
Hmm, one thing I notice in Matlab is that the returned string is actually one
longer than the length argument. So
>> rats (2.0005, 9)
ans = ' 4001/2000'
returns a string of length 10. If it is negative,
>> rats (-2.0005, 9)
ans = ' * '
the return value is still length 10, but a star because the negative sign
leaves no room for the space at the beginning.
So it looks to me like at least one leading space is always present, and
doesn't count against the number of characters the user requested.
I think the point of this additional leading space is so the user can just
slap the strings together and they are implicitly space-padded. And no extra
space needs to be inserted when operating on a row vector, for example
>> x = rand (1, 2);
>> size (rats (x(1), 10))
ans =
1 11
>> size (rats (x, 10))
ans =
1 22
IMHO it would be nice to be compatible in all of these cases.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57704>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/