[R] bug?
Marc Schwartz
MSchwartz at medanalytics.com
Mon Jul 14 15:58:48 CEST 2003
On Mon, 2003-07-14 at 03:10, Uwe Ligges wrote:
> Marc Vandemeulebroecke wrote:
>
> > Dear R programmers,
> >
> > is there a sensible explanation for the following behaviour? The second
> > command seems not to be interpreted correctly.
> >
> >
> >>seq(0.6, 0.9, by=0.1) == 0.8
> >
> > [1] FALSE FALSE TRUE FALSE
> >
> >>seq(0.7, 0.9, by=0.1) == 0.8
> >
> > [1] FALSE FALSE FALSE
> >
> >>c(0.7, 0.8, 0.9) == 0.8
> >
> > [1] FALSE TRUE FALSE
> >
> >>seq(0.9, 0.7, by=-0.1) == 0.8
> >
> > [1] FALSE TRUE FALSE
> >
> > I am running R version 1.7.1 on XP and NT.
> >
> > Thanks,
> > Marc
> >
> > --
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>
> It is correct, just an instability of the representation of that
> floating point number, because (regularly) floating point numbers cannot
> be represented exactly.
>
> Uwe Ligges
An good online reference for these issues is at:
http://grouper.ieee.org/groups/754/
Specifically, the article by David Goldberg entitled "What Every
Computer Scientist Should Know about Floating-Point Arithmetic", which
is listed toward the bottom of that page.
HTH,
Marc Schwartz
More information about the R-help
mailing list