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

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

[Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead


From: Ben Kurtz
Subject: [Octave-bug-tracker] [bug #39838] str2double ('') gives [](0x1) instead of NaN
Date: Sun, 01 Sep 2013 04:03:34 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1

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

And here's my (belated, sorry) patch implementing the changes I suggested:
* char data with either rows or columns equal to zero returns a scalar NaN.
* non-char data of any size also converts to scalar NaN.  It seemed silly to
match the size of non-char data, since you have no idea what kind of data it's
trying to represent (e.g. str2double(double("123.5")) likely shouldn't be
nan(1,5)).

This leaves us slightly different from matlab, in that matlab treats an MxN
char matrix as a single 1x(M*N) string, reading down the columns, which is
simply an absurd interpretation of a char array.  I think octave's existing
implementation in that case - namely, to convert each row separately - makes
good sense, so I left that exactly as is, except of course for the empty
cases.  Note that there aren't cases where some rows are empty (length 0) and
some rows have valid data, because all rows must have the same length. 
Storing multi-row string data in a single char seems like a bad idea in
general for this reason, but at least we can _try_ to work with people on
that.

(file #28971)
    _______________________________________________________

Additional Item Attachment:

File name: str2double_empties.patch       Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?39838>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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