0

the following results in all FALSE:

> seq(.1,.5,.1)==.3
[1] FALSE FALSE FALSE FALSE FALSE

but then these examples work properly:

> seq(.1,.5,.1)==.1
[1]  TRUE FALSE FALSE FALSE FALSE
> seq(.1,.5,.1)==.2
[1] FALSE  TRUE FALSE FALSE FALSE
> seq(.1,.5,.1)==.3
[1] FALSE FALSE FALSE FALSE FALSE
> seq(.1,.5,.1)==.4
[1] FALSE FALSE FALSE  TRUE FALSE
> seq(.1,.5,.1)==.5
[1] FALSE FALSE FALSE FALSE  TRUE

Am I missing something????

road_to_quantdom
  • 1,331
  • 1
  • 12
  • 20
  • 3
    Floating point math is messy. Try something like `seq(1,5,1)/10==.3` instead. In general it's a bad idea to try to test for equality with floating point values. – MrFlick Sep 16 '21 at 22:00

0 Answers0