[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
comparing numbers using WHERE doesn't work
- Subject: comparing numbers using WHERE doesn't work
- From: "Miklos Z. Kiss" <mzkiss(at)unity.ncsu.edu>
- Date: Sat, 2 Jun 2001 15:15:16 -0400
- Newsgroups: comp.lang.idl-pvwave
- Organization: NC State University
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:25191
I have noticed a strange occurence when I try to compare a number with
all the elements of an array. I'll show my situation in an example.
Consider the following array:
a = [2.0000, 2.1000, 2.2000, 2.3000, 2.4000, 2.5000, 2.6000].
Let, x = 2.2000, y = 2.4000
So, I want to find which elements of a match up with x and y.
Naturally, I do the following:
index0 = WHERE(a EQ x)
index0 = index ; convert from 1-D array to single integer.
index1 = WHERE(a EQ y)
index1 = index
So, when I execute, I may get the following:
The output clearly tells me that x occurs at a and that y does not exist
in a at all. By inspection, IDL should return the value 4. Does anyone
have any idea why this happens? Thanks,