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: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: In ProgressAssigned to: Rik <rik5>
Originator Name: Philip NienhuisOpen/Closed: Closed
Release: devOperating 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?

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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 30 May 2012 12:46:39 AM UTCrik5CategoryNone=>Libraries
      Item GroupIncorrect Result=>Matlab Compatibility
      Open/ClosedOpen=>Closed
    Sun 27 May 2012 09:35:36 PM UTCrik5StatusNeed Info=>In Progress
      Assigned toNone=>rik5
    Sat 26 May 2012 04:18:16 AM UTCrik5StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1