0

I'm working with matrices in R, and noticed something strange:

set.seed(1234)
m <- replicate(10, rnorm(20))
all(m / 7 == m * (1/7)) #FALSE

Why is that ? Shouldn't the multiplication by the reciprocal be equivalent to normal division ?

hshihab
  • 416
  • 5
  • 16

1 Answers1

0

Because of the imprecision resulting from floating-point arithmetic. You should find that the values are very close.

fgregg
  • 3,173
  • 30
  • 37