octave-maintainers
[Top][All Lists]
Advanced

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

Re: str2double API changes


From: Carnë Draug
Subject: Re: str2double API changes
Date: Mon, 6 Jun 2011 17:23:01 +0100

On 6 June 2011 16:56, Julien Salort <address@hidden> wrote:
> Carnë Draug <address@hidden> writes:
>
>> Hi could you please test on your MatLab
>>
>>> str2double(45)
>>
>> Does it return an error or 'NaN'? That's what has changed. It used to
>> return NaN, now it returns an error. Thank you
>
> On my Matlab:
>
>>> str2double(45)
>
> ans =
>
>   NaN

Thank you. So the new implementation choice about how to handle bad
inputs also seems to break the compatibility with MatLab (which
existed before) and old octave versions.

I don't know C so the only workaround I have at the moment is to make
a new function that calls the C optimized version of str2double adn in
case of errors replaces all non-strings by strings:

function out = str2double(in)
try
  out = str2double_optimized (in)
catch
  for i:1:numel(in)
    if (!ischar (a{i})) a{i} = "nan"; endif
  endfor
  out = str2double_optimized (in)
end_try_catch

I'm sure someone smarter will think of something better than this.

Carnë


reply via email to

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