[R] Basic question on function "identical"

Thomas Lumley tlumley at u.washington.edu
Mon Dec 15 16:15:02 CET 2003


On Sat, 13 Dec 2003 Ted.Harding at nessie.mcc.ac.uk wrote:

> On 13-Dec-03 Martin Maechler wrote:
> > In general, use
> >
> >   ==       for testing equality of integer numbers (of type "integer"
> >            or not)
>
> I hope this is not a suggestion to avoid usage like
>
>   which(x == max(x))
>
> when x is a vector of reals? (i.e. should be OK when you know that
> the thing on one side of == should be an exact copy in its internal
> representation of the thing on the other side, if equality in the
> usual sense holds).
>
> In other words, I hope that (for instance) max(x) does not differ
> internally from whichever of x[1] , ... , x[N] has the largest value ...
>

One reason that which.max() exists is that we cannot guarantee
which(x==max(x)) to work. It is possible, though rather unlikely, for
there to be no x such that x==max(x).  One reason is the unpredictable
use of 10-byte wide floating point registers on Intel chips.


	-thomas




More information about the R-help mailing list