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

 
 

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

Submitted by:  Dildar Sk <hodor123456>
Submitted on:  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

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

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>
Project 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
  •  

    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 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 dildarsk101010@gmail.com

    Back to the top


    Powered by Savane 3.5