MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MemberQ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68533] Re: MemberQ
  • From: "Scout" <Scout at nodomain.com>
  • Date: Wed, 9 Aug 2006 04:18:55 -0400 (EDT)
  • References: <eb9pkt$t4j$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Bruce Colletti" <vze269bv at verizon.net>
news:eb9pkt$t4j$1 at smc.vnet.net...
> Re Mathematica 5.2.0.0.
>
> Since 0.7 is in the set {0.0, 0.1, 0.2,..., 0.9, 1.0}, why does 
> MemberQ[Range[0., 1., .1], .7] return False?
>
> Thankx.
>
> Bruce
>

Hi Bruce,
you could have strange behaviors if you try to compare real numbers.
It could happen that on different systems that equality gives True.
I suggest you to use an alternative representation for Reals or to try to 
use the operator ==
with commands such as Rationalize[], Round[], Chop [], N [], etc.

Using exact Rational numbers:
        In[]:= i=Range[0, 1, 1/10];
        In[]:= MemberQ[i, 7/10]
        Out[]= True

HTH,
    ~Scout~ 


  • Prev by Date: Re: How to get the output of Minimize function in x = a format
  • Next by Date: Re: How to get the output of Minimize function in x = a format
  • Previous by thread: Re: MemberQ
  • Next by thread: Re: MemberQ