bugGNU Octave - Bugs: bug #53472, primes.m: char input producing...

 
 

bug #53472: primes.m: char input producing weird behaviours

Submitter:  Dildar Sk <hodor123456>
Submitted:  Mon 26 Mar 2018 09:37:44 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Dildar Sk Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 12 Apr 2018 08:23:45 PM UTC, comment #2: 

I think it is better to use strict input validation.  If a programmer has typed


primes ('1')


it is more likely to be an error then the intended result.  If they really want to know all primes less than 49 then they can explicitly say so by converting the character to a number with double().


primes (double ('1'))


I tightened the input validation in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/8a92b651838b).

Marking as fixed and closing report.


Rik <rik5>
Group administrator
Mon 26 Mar 2018 09:42:55 AM UTC, comment #1: 

I tried to handle the result by changing the char input
to it's ascii value as MATLAB handles. Patch attached.

(file #43680)

Dildar Sk <hodor123456>
Mon 26 Mar 2018 09:37:44 AM UTC, original submission:  

In MATLAB,


>> primes('1')

ans =

     2     3     5     7    11    13    17    19    23    29    31    37    41    43    47

>>


So, MATLAB simply chooses to convert it to ascii value and give result. Where in Octave,


>> primes('1')
ans =
%)+/
>> primes('5')
ans =
%)+/5
>> primes('a')
ans =
%)+/5;=CGIOSYa
>> primes('b')
ans =
%)+/5;=CGIOSYa
>> primes(' ')
ans =


Producing different weird result for different inputs but not error, warning or correct result.

Dildar Sk <hodor123456>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43680:  primes.patch added by hodor123456 (705B - text/x-patch)

 

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 hodor123456 (Submitted the item)
  • -email is unavailable- added by hodor123456
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-12 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2018-03-26 hodor123456 Attached File- Added primes.patch, #43680
    2018-03-26 hodor123456 Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code