# MemberQ not working? [duplicate]

I'm confused by the following trivial code:

{Range[0, 1, .1][[8]]} === {.7}


gives True

MemberQ[{.7}, .7]


gives True, but

MemberQ[{Range[0, 1, .1][[8]]}, .7]


gives False. Huh? What am I missing?

• {Range[0, 1, .1][[8]], .7} // InputForm ought to be enlightening. Moral lesson is that you don't do such pattern matches on inexact numbers. – J. M. will be back soon Aug 6 '17 at 12:53
• @J.M. thanks, I thought it might be a floating point thing, but then I was surprised by the first equality, which I still don't understand – bjorne Aug 6 '17 at 12:55
• That would be due to Internal$SameQTolerance (or Internal$EqualTolerance if you had used ==). See e.g. this. – J. M. will be back soon Aug 6 '17 at 12:59
• @J.M. Great, thanks! – bjorne Aug 6 '17 at 13:00
• Recommended reading: (5149), (5580), (21711), (66386), (86815). Please take a look at these and tell me if you feel that your question is adequately addressed in these. If so we can mark it as such. – Mr.Wizard Aug 6 '17 at 17:07