2
$\begingroup$

I have defined a list

profilelength={0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., \
15., 16., 17., 18., 19., 20., 22., 24., 26., 28., 30., 32., 34., 36., \
38., 40., 42., 44., 46., 48., 50., 52., 54., 56., 58., 60., 62., 64., \
66., 68., 70., 72., 74., 76., 78., 80., 82., 84., 86., 88., 90., 92., \
94., 96., 98., 100.}

than I defined a parameter

a=0.56;

And tried to find it's position in the table. But really strange this doesn't work:

Position[profilelength[[All]], N[a*100]][[1, 1]]

but this works:

Position[profilelength[[All]], 56.][[1, 1]]

Now I don't understand why on earth this happens and what to do about it?

$\endgroup$
  • 2
    $\begingroup$ This is a case of machine-precision gremlins. You need something like Position[profilelength, x_ /; x == N[a*100]] instead. This question is a duplicate; I shall look for the original. $\endgroup$ – Mr.Wizard Sep 15 '15 at 9:03
  • 5
    $\begingroup$ Proposed duplicate: (15907) $\endgroup$ – Mr.Wizard Sep 15 '15 at 9:04

Browse other questions tagged or ask your own question.