bugGNU Octave - Bugs: bug #47106, finding values in a vector with...

 
 

bug #47106: finding values in a vector with for-loop and if-statement

Submitter:  santico jinotir <sanjin>
Submitted:  Wed 10 Feb 2016 02:16:31 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  sanjin Open/Closed:  * Closed
Release:  * 3.8.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 10 Feb 2016 02:52:18 AM UTC, comment #1: 

Thanks for taking the time to file a report, but this is not a bug, this is normal floating point precision at work.

Compare the results with your definition


x = 0:.2:3;


and this one


x = [0:15] ./ 5;


And use this code to show the values of the elements that are not exactly what you think they are:


[~, ~, y] = find (rem ([0:.2:3] .* 5, 1))


This is also documented in the manual: https://www.gnu.org/software/octave/doc/interpreter/Ranges.html

Mike Miller <mtmiller>
Group Member
Wed 10 Feb 2016 02:16:31 AM UTC, original submission:  

Hello,

I am having problems finding values in a vector using a for-loop and an if-statement. I think this is a bug.

When I run the for loop below the if-statement does not find the value x=2.8 or x=2.4 and others...

*I am running openSUSE 13.2
*Octave version 3.8.2.
*Octave was configured for "x86_64-suse-linux-gnu"



x=0:.2:3;

for i=1:length(x)

x(i)

if x(i)==2.8
fprintf('value found')
end

end


santico jinotir <sanjin>

 

(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 mtmiller (Posted a comment)
  • -email is unavailable- added by sanjin (Submitted the item)
  •  

    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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-10 mtmiller StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code