octave-maintainers
[Top][All Lists]
Advanced

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

Re: str2double API changes


From: Rik
Subject: Re: str2double API changes
Date: Sat, 04 Jun 2011 15:42:16 -0700

On 06/04/2011 10:00 AM, address@hidden wrote:
> I just upgraded to 3.4 and noticed that the API for str2double is
> slightly different. It no longer returns the status of the conversion.
> Was this removal on purpose when rewriting for C or it was just
> forgotten (just asking because it's also doesn't appear on the NEWS
> hence my surprise).
> 
> It used to work this way
> 
> [num, status] = str2double {'32, '23', 45'}
> 
> where status would be a cell array of the same division of the input
> with values of 0 or -1 whether it succeeded or not on the conversion.
The new behavior (i.e., no extra return status) makes the function Matlab
compatible.  The documentation for str2double from Mathworks is here:
http://www.mathworks.com/help/techdoc/ref/str2double.html.
> 
> Another change of this function is that if one of the values is not a
> string, it returns the error: "str2double: wrong type argument `cell'"
> while it used to simply return the value 'NaN' for those cases.
Only strings or cellstrings are valid input so there is an implementation
choice about how to handle bad inputs.  How does Matlab handle the following:

str2double ({ "1.5", [2.5] })

> 
> Also, the documentation doesn't state that it returns 'NaN' on a
> failed conversion. I don't know C so this is all I can help with (see
> attached patch). Sorry that I can't be of more help.
I'll change the documentation to make this clear and also add something to
the NEWS file about the API change.  Thanks for noticing this.

--Rik


reply via email to

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