bugGNU Octave - Bugs: bug #36536, str2double is case-sensitive

 
 

bug #36536: str2double is case-sensitive

Submitted by:  Philip Nienhuis <philipnienhuis>
Submitted on:  Thu 24 May 2012 09:57:17 PM UTC  
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  In Progress Assigned to:  Rik <rik5>
Originator Name:  Philip Nienhuis Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 30 May 2012 12:46:39 AM UTC, comment #4: 

I have made str2double case-insensitive for 'inf' which matches Matlab behavior here (http://hg.savannah.gnu.org/hgweb/octave/rev/a08f6e17336e).  Closing report.

Rik <rik5>
Project AdministratorIn charge of this item.
Sat 26 May 2012 03:42:39 PM UTC, comment #3: 

>> ver

MATLAB Version 7.4.0.287 (R2007a)

>> str2double ('I')

ans =
   NaN

>> str2double ('2I')

ans =
   NaN

>> str2double ('2*I')

ans =
   NaN

>> str2double ('I + 2*I')

ans =
   NaN

>> str2double ('I + inf*i')

ans =
   NaN

>> str2double ('i + inf*i')

ans =
   NaN

>>


NOTE this is r2007a which was quite buggy. OTOH it gives the same answers to the calls in comment #1.

Philip Nienhuis <philipnienhuis>
Project Member
Sat 26 May 2012 04:18:16 AM UTC, comment #2: 

I have a patch that implements most of this, but I want to know if Matlab handles a capital 'I' for the imaginary unit.  Can you try the following?

str2double ('I')
str2double ('2I')
str2double ('2*I')
str2double ('1 + 2*I')
str2double ('1 + inf*i')

Rik <rik5>
Project AdministratorIn charge of this item.
Fri 25 May 2012 12:01:59 PM UTC, comment #1: 

ML r2009a has this to say:

>> str2double ('inf')

ans =
   Inf

>> str2double ('iNF')

ans =
   Inf

>> str2double ('Inf')

ans =
   Inf

>> str2double ('INF')

ans =
   Inf

>> str2num ('inf')

ans =
   Inf

>> str2num ('iNF')

ans =
     []

>> str2num ('Inf')

ans =
   Inf

>> str2num ('inF')

ans =
     []

>> str2num ('InF')

ans =
     []

>>  str2num ('INF')

ans =
     []

so it seems the situation is a bit reversed compared to Octave: str2double is case-INsensitive while str2num is.

I'd vote for making at least str2double ML-compatible.

Philip Nienhuis <philipnienhuis>
Project Member
Thu 24 May 2012 09:57:17 PM UTC, original submission:  

octave-3.6.1:1> str2double ('Inf')
ans = Inf
octave-3.6.1:2> str2double ('inf')
ans = NaN
octave-3.6.1:3> str2double ('NaN')
ans = NaN
octave-3.6.1:4> str2double ('Naa')
ans = NaN
octave-3.6.1:5> str2num ('Inf')
ans = Inf
octave-3.6.1:6> str2num ('inf')
ans = Inf

Obviously str2double returns NaN for any read "error".
But that it is case-sensitive while str2num is not, is inconsistent.

I don't have ML at hand at the moment, but IIRC in ML both str2num and str2double are case-INsensitive. Can someone check, please?

Philip Nienhuis <philipnienhuis>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by philipnienhuis (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-05-30 rik5 CategoryNone => Libraries
        Item GroupIncorrect Result => Matlab Compatibility
        Open/ClosedOpen => Closed
    2012-05-27 rik5 StatusNeed Info => In Progress
        Assigned toNone => rik5
    2012-05-26 rik5 StatusNone => Need Info

    Back to the top


    Powered by Savane 3.5