Monday, 12 August 2013

Why does floor() give unexpected result in r?

Why does floor() give unexpected result in r?

Here is some output from r:
> (567.8 - floor(567.8)) * 10
[1] 8
> x <-(567.8 - floor(567.8)) * 10
> floor(x)
[1] 7
I would have though the last value would return 8, especially when
floor(8) returns 8.
Any ideas why this is happening and how I can get around it?

No comments:

Post a Comment